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


Python v8_utilities.has_extended_attribute_value函数代码示例

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


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

示例1: 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

示例2: argument_context

def argument_context(interface, method, argument, index):
    extended_attributes = argument.extended_attributes
    idl_type = argument.idl_type
    this_cpp_value = cpp_value(interface, method, index)
    is_variadic_wrapper_type = argument.is_variadic 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.")

    default_cpp_value = argument.default_cpp_value
    return {
        "cpp_type": idl_type.cpp_type_args(
            extended_attributes=extended_attributes, raw_type=True, used_as_variadic_argument=argument.is_variadic
        ),
        "cpp_value": this_cpp_value,
        # FIXME: check that the default value's type is compatible with the argument's
        "default_value": default_cpp_value,
        "enum_validation_expression": idl_type.enum_validation_expression,
        "handle": "%sHandle" % argument.name,
        # FIXME: remove once [Default] removed and just use argument.default_value
        "has_default": "Default" in extended_attributes or default_cpp_value,
        "has_type_checking_interface": (
            has_extended_attribute_value(interface, "TypeChecking", "Interface")
            or has_extended_attribute_value(method, "TypeChecking", "Interface")
        )
        and idl_type.is_wrapper_type,
        "has_type_checking_unrestricted": (
            has_extended_attribute_value(interface, "TypeChecking", "Unrestricted")
            or has_extended_attribute_value(method, "TypeChecking", "Unrestricted")
        )
        and idl_type.name in ("Float", "Double"),
        # 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_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_nullable": idl_type.is_nullable,
        "is_optional": argument.is_optional,
        "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()"
        ),
        "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(
            argument, index, return_promise=method.returns_promise
        ),
        "vector_type": v8_types.cpp_ptr_type("Vector", "HeapVector", idl_type.gc_type),
    }
开发者ID:wulala-wuwu,项目名称:Blink,代码行数:59,代码来源:v8_methods.py

示例3: argument_context

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

    type_checking_interface = (
        (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or
         has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and
        idl_type.is_wrapper_type)

    type_checked = (type_checking_interface and
                    # These allow null and undefined values, so a type-check is still required.
                    not idl_type.is_nullable and
                    not (argument.is_optional and
                         'Default' in extended_attributes))

    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.')

    default_cpp_value = argument.default_cpp_value
    return {
        'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attributes,
                                           raw_type=True,
                                           used_as_variadic_argument=argument.is_variadic),
        'cpp_value': this_cpp_value,
        # FIXME: check that the default value's type is compatible with the argument's
        'default_value': default_cpp_value,
        'enum_validation_expression': idl_type.enum_validation_expression,
        'handle': '%sHandle' % argument.name,
        # FIXME: remove once [Default] removed and just use argument.default_value
        'has_default': 'Default' in extended_attributes or default_cpp_value,
        'has_type_checking_interface': type_checking_interface,
        'has_type_checking_unrestricted':
            (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted') or
             has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted')) and
            idl_type.name in ('Float', 'Double'),
        # 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_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_nullable': idl_type.is_nullable,
        'is_optional': argument.is_optional,
        '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()'),
        '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(argument, index, type_checked, return_promise=method.returns_promise),
        'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc_type),
    }
开发者ID:smilusingjavascript,项目名称:blink,代码行数:59,代码来源:v8_methods.py

示例4: attribute_context

def attribute_context(interface, attribute):
    idl_type = attribute.idl_type
    base_idl_type = idl_type.base_type
    extended_attributes = attribute.extended_attributes

    idl_type.add_includes_for_type()

    # [TypeChecking]
    has_type_checking_unrestricted = (
        (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted') or
         has_extended_attribute_value(attribute, 'TypeChecking', 'Unrestricted')) and
         idl_type.name in ('Float', 'Double'))

    context = {
        'argument_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),
        'cached_attribute_validation_method': extended_attributes.get('CachedAttribute'),
        'constructor_type': idl_type.constructor_type_name
                            if is_constructor_attribute(attribute) else None,
        'cpp_name': cpp_name(attribute),
        'cpp_type': idl_type.cpp_type,
        'cpp_type_initializer': idl_type.cpp_type_initializer,
        'enum_validation_expression': idl_type.enum_validation_expression,
        'exposed_test': v8_utilities.exposed(attribute, interface),  # [Exposed]
        'has_custom_getter': has_custom_getter(attribute),
        'has_custom_setter': has_custom_setter(attribute),
        'has_type_checking_unrestricted': has_type_checking_unrestricted,
        'idl_type': str(idl_type),  # need trailing [] on array for Dictionary::ConversionContext::setConversionType
        'is_call_with_execution_context': v8_utilities.has_extended_attribute_value(attribute, 'CallWith', 'ExecutionContext'),
        'is_call_with_script_state': v8_utilities.has_extended_attribute_value(attribute, 'CallWith', 'ScriptState'),
        'is_getter_raises_exception':  # [RaisesException]
            'RaisesException' in extended_attributes and
            extended_attributes['RaisesException'] in (None, 'Getter'),
        'is_initialized_by_event_constructor':
            'InitializedByEventConstructor' in extended_attributes,
        'is_keep_alive_for_gc': is_keep_alive_for_gc(interface, attribute),
        'is_nullable': idl_type.is_nullable,
        'is_explicit_nullable': idl_type.is_explicit_nullable,
        'is_partial_interface_member':
            'PartialInterfaceImplementedAs' in extended_attributes,
        'is_read_only': attribute.is_read_only,
        'is_replaceable': 'Replaceable' in attribute.extended_attributes,
        'is_static': attribute.is_static,
        'is_url': 'URL' in extended_attributes,
        'name': attribute.name,
        'put_forwards': 'PutForwards' in extended_attributes,
        'setter_callback': setter_callback_name(interface, attribute),
    }

    if is_constructor_attribute(attribute):
        constructor_getter_context(interface, attribute, context)
        return context
    if not has_custom_getter(attribute):
        getter_context(interface, attribute, context)
    if (not has_custom_setter(attribute) and
        (not attribute.is_read_only or 'PutForwards' in extended_attributes)):
        setter_context(interface, attribute, context)

    return context
开发者ID:MitchRudominer,项目名称:engine,代码行数:58,代码来源:v8_attributes.py

示例5: setter_context

def setter_context(interface, attribute, context):
    if "PutForwards" in attribute.extended_attributes:
        # Use target interface and attribute in place of original interface and
        # attribute from this point onwards.
        target_interface_name = attribute.idl_type.base_type
        target_attribute_name = attribute.extended_attributes["PutForwards"]
        interface = interfaces[target_interface_name]
        try:
            attribute = next(candidate for candidate in interface.attributes if candidate.name == target_attribute_name)
        except StopIteration:
            raise Exception(
                "[PutForward] target not found:\n"
                'Attribute "%s" is not present in interface "%s"' % (target_attribute_name, target_interface_name)
            )

    extended_attributes = attribute.extended_attributes
    idl_type = attribute.idl_type

    # [RaisesException], [RaisesException=Setter]
    is_setter_raises_exception = "RaisesException" in extended_attributes and extended_attributes[
        "RaisesException"
    ] in [None, "Setter"]
    # [TypeChecking=Interface]
    has_type_checking_interface = (
        has_extended_attribute_value(interface, "TypeChecking", "Interface")
        or has_extended_attribute_value(attribute, "TypeChecking", "Interface")
    ) and idl_type.is_wrapper_type

    type_checked = (
        has_type_checking_interface
        and
        # These allow null values, so a type-check is still required.
        not idl_type.is_nullable
    )

    context.update(
        {
            "has_setter_exception_state": is_setter_raises_exception
            or has_type_checking_interface
            or context["has_type_checking_unrestricted"]
            or idl_type.v8_conversion_needs_exception_state,
            "has_type_checking_interface": has_type_checking_interface,
            "is_setter_call_with_execution_context": v8_utilities.has_extended_attribute_value(
                attribute, "SetterCallWith", "ExecutionContext"
            ),
            "is_setter_raises_exception": is_setter_raises_exception,
            "private_script_cpp_value_to_v8_value": idl_type.cpp_value_to_v8_value(
                "cppValue", isolate="scriptState->isolate()", creation_context="scriptState->context()->Global()"
            ),
            "v8_value_to_local_cpp_value": idl_type.v8_value_to_local_cpp_value(
                extended_attributes, "v8Value", "cppValue", needs_type_check=not type_checked
            ),
        }
    )

    # setter_expression() depends on context values we set above.
    context["cpp_setter"] = setter_expression(interface, attribute, context)
开发者ID:syncfusion,项目名称:SfQtWebKit,代码行数:57,代码来源:v8_attributes.py

示例6: setter_context

def setter_context(interface, attribute, context):
    if 'PutForwards' in attribute.extended_attributes:
        # Use target interface and attribute in place of original interface and
        # attribute from this point onwards.
        target_interface_name = attribute.idl_type.base_type
        target_attribute_name = attribute.extended_attributes['PutForwards']
        interface = interfaces[target_interface_name]
        try:
            attribute = next(candidate
                             for candidate in interface.attributes
                             if candidate.name == target_attribute_name)
        except StopIteration:
            raise Exception('[PutForward] target not found:\n'
                            'Attribute "%s" is not present in interface "%s"' %
                            (target_attribute_name, target_interface_name))

    extended_attributes = attribute.extended_attributes
    idl_type = attribute.idl_type

    # [RaisesException], [RaisesException=Setter]
    is_setter_raises_exception = (
        'RaisesException' in extended_attributes and
        extended_attributes['RaisesException'] in [None, 'Setter'])
    # [TypeChecking=Interface]
    has_type_checking_interface = (
        (has_extended_attribute_value(interface, 'TypeChecking', 'Interface') or
         has_extended_attribute_value(attribute, 'TypeChecking', 'Interface')) and
        idl_type.is_wrapper_type)

    type_checked = (has_type_checking_interface and
                    # These allow null values, so a type-check is still required.
                    not idl_type.is_nullable)

    context.update({
        'has_setter_exception_state':
            is_setter_raises_exception or has_type_checking_interface or
            context['has_type_checking_unrestricted'] or
            idl_type.v8_conversion_needs_exception_state,
        'has_type_checking_interface': has_type_checking_interface,
        'is_setter_call_with_execution_context': v8_utilities.has_extended_attribute_value(
            attribute, 'SetterCallWith', 'ExecutionContext'),
        'is_setter_raises_exception': is_setter_raises_exception,
        'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
            'cppValue', isolate='scriptState->isolate()',
            creation_context='scriptState->context()->Global()'),
        'v8_value_to_local_cpp_value': idl_type.v8_value_to_local_cpp_value(
            extended_attributes, 'v8Value', 'cppValue',
            needs_type_check=not type_checked),
    })

    # setter_expression() depends on context values we set above.
    context['cpp_setter'] = setter_expression(interface, attribute, context)
开发者ID:smilusingjavascript,项目名称:blink,代码行数:52,代码来源:v8_attributes.py

示例7: constructor_arguments

def constructor_arguments(interface):
    arguments = []
    # [ConstructorCallWith=ExecutionContext]
    if has_extended_attribute_value(interface, 'ConstructorCallWith', 'ExecutionContext'):
        arguments.append('context')
    # [ConstructorCallWith=Document]
    if has_extended_attribute_value(interface, 'ConstructorCallWith', 'Document'):
        arguments.append('document')
    # FIXME: actual arguments!
    # [RaisesException=Constructor]
    if interface.extended_attributes.get('RaisesException') == 'Constructor':
        arguments.append('exceptionState')
    return arguments
开发者ID:Igalia,项目名称:blink,代码行数:13,代码来源:v8_interface.py

示例8: property_getter

def property_getter(getter, cpp_arguments):
    def is_null_expression(idl_type):
        if v8_types.is_union_type(idl_type):
            return ' && '.join('!result%sEnabled' % i
                               for i, _ in
                               enumerate(idl_type.union_member_types))
        if idl_type == 'DOMString':
            return 'result.isNull()'
        if is_interface_type(idl_type):
            return '!result'
        return ''

    idl_type = getter.idl_type
    extended_attributes = getter.extended_attributes
    is_raises_exception = 'RaisesException' in extended_attributes

    if v8_types.is_union_type(idl_type):
        release = [v8_types.is_interface_type(union_member_type)
                   for union_member_type in idl_type.union_member_types]
    else:
        release = v8_types.is_interface_type(idl_type)

    # FIXME: make more generic, so can use v8_methods.cpp_value
    cpp_method_name = 'imp->%s' % cpp_name(getter)

    if is_raises_exception:
        cpp_arguments.append('exceptionState')
    this_union_arguments = v8_methods.union_arguments(idl_type)
    if this_union_arguments:
        cpp_arguments.extend(this_union_arguments)

    cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))

    return {
        'cpp_type': v8_types.cpp_type(idl_type),
        'cpp_value': cpp_value,
        'is_custom':
            'Custom' in extended_attributes and
            (not extended_attributes['Custom'] or
             has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')),
        'is_custom_property_enumerator': has_extended_attribute_value(
            getter, 'Custom', 'PropertyEnumerator'),
        'is_custom_property_query': has_extended_attribute_value(
            getter, 'Custom', 'PropertyQuery'),
        'is_enumerable': 'NotEnumerable' not in extended_attributes,
        'is_null_expression': is_null_expression(idl_type),
        'is_raises_exception': is_raises_exception,
        'name': cpp_name(getter),
        'union_arguments': v8_methods.union_arguments(idl_type),
        'v8_set_return_value': v8_types.v8_set_return_value(idl_type, 'result', extended_attributes=extended_attributes, script_wrappable='imp', release=release),
    }
开发者ID:glenkim-dev,项目名称:blink-crosswalk,代码行数:51,代码来源:v8_interface.py

示例9: use_local_result

def use_local_result(method):
    extended_attributes = method.extended_attributes
    idl_type = method.idl_type
    return (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or
            'RaisesException' in extended_attributes or
            idl_type.is_union_type or
            idl_type.is_explicit_nullable)
开发者ID:MitchRudominer,项目名称:engine,代码行数:7,代码来源:v8_methods.py

示例10: constructor_argument_list

def constructor_argument_list(interface, constructor):
    arguments = []
    # [ConstructorCallWith=ExecutionContext]
    if has_extended_attribute_value(interface, 'ConstructorCallWith', 'ExecutionContext'):
        arguments.append('context')
    # [ConstructorCallWith=Document]
    if has_extended_attribute_value(interface, 'ConstructorCallWith', 'Document'):
        arguments.append('document')

    arguments.extend([argument.name for argument in constructor.arguments])

    # [RaisesException=Constructor]
    if interface.extended_attributes.get('RaisesException') == 'Constructor':
        arguments.append('exceptionState')

    return arguments
开发者ID:junmin-zhu,项目名称:blink,代码行数:16,代码来源:v8_interface.py

示例11: property_getter

def property_getter(getter, cpp_arguments):
    def is_null_expression(idl_type):
        if idl_type.is_union_type:
            notnull = ' || '.join([
                    member_argument['null_check_value']
                    for member_argument in idl_type.union_arguments])
            return '!(%s)' % notnull
        if idl_type.name == 'String':
            return 'result.isNull()'
        if idl_type.is_interface_type:
            return '!result'
        return ''

    idl_type = getter.idl_type
    extended_attributes = getter.extended_attributes
    is_raises_exception = 'RaisesException' in extended_attributes

    # FIXME: make more generic, so can use v8_methods.cpp_value
    cpp_method_name = 'impl->%s' % cpp_name(getter)

    if is_raises_exception:
        cpp_arguments.append('exceptionState')
    union_arguments = idl_type.union_arguments
    if union_arguments:
        cpp_arguments.extend([member_argument['cpp_value']
                              for member_argument in union_arguments])

    cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))

    return {
        'cpp_type': idl_type.cpp_type,
        'cpp_value': cpp_value,
        'is_custom':
            'Custom' in extended_attributes and
            (not extended_attributes['Custom'] or
             has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')),
        'is_custom_property_enumerator': has_extended_attribute_value(
            getter, 'Custom', 'PropertyEnumerator'),
        'is_custom_property_query': has_extended_attribute_value(
            getter, 'Custom', 'PropertyQuery'),
        'is_enumerable': 'NotEnumerable' not in extended_attributes,
        'is_null_expression': is_null_expression(idl_type),
        'is_raises_exception': is_raises_exception,
        'name': cpp_name(getter),
        'union_arguments': union_arguments,
        'v8_set_return_value': idl_type.v8_set_return_value('result', extended_attributes=extended_attributes, script_wrappable='impl', release=idl_type.release),
    }
开发者ID:335969568,项目名称:Blink-1,代码行数:47,代码来源:v8_interface.py

示例12: cpp_value

def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        idl_type = argument.idl_type
        if idl_type.name == "EventListener":
            return argument.name
        if idl_type.is_dictionary:
            return "*%s" % argument.name
        if idl_type.name in ["NodeFilter", "NodeFilterOrNull", "XPathNSResolver", "XPathNSResolverOrNull"]:
            # FIXME: remove this special case
            return "%s.release()" % argument.name
        return argument.name

    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = []
    if "ImplementedInPrivateScript" in method.extended_attributes:
        cpp_arguments.append("toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext())")
        cpp_arguments.append("impl")

    if method.is_constructor:
        call_with_values = interface.extended_attributes.get("ConstructorCallWith")
    else:
        call_with_values = method.extended_attributes.get("CallWith")
    cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values))

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if (
        "PartialInterfaceImplementedAs" in method.extended_attributes
        and not "ImplementedInPrivateScript" in method.extended_attributes
        and not method.is_static
    ):
        cpp_arguments.append("*impl")
    cpp_arguments.extend(cpp_argument(argument) for argument in arguments)

    this_union_arguments = method.idl_type and method.idl_type.union_arguments
    if this_union_arguments:
        cpp_arguments.extend([member_argument["cpp_value"] for member_argument in this_union_arguments])

    if "ImplementedInPrivateScript" in method.extended_attributes:
        if method.idl_type.name != "void":
            cpp_arguments.append("&result")
    elif "RaisesException" in method.extended_attributes or (
        method.is_constructor and has_extended_attribute_value(interface, "RaisesException", "Constructor")
    ):
        cpp_arguments.append("exceptionState")

    if method.name == "Constructor":
        base_name = "create"
    elif method.name == "NamedConstructor":
        base_name = "createForJSConstructor"
    elif "ImplementedInPrivateScript" in method.extended_attributes:
        base_name = "%sMethod" % method.name
    else:
        base_name = v8_utilities.cpp_name(method)

    cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
    return "%s(%s)" % (cpp_method_name, ", ".join(cpp_arguments))
开发者ID:wulala-wuwu,项目名称:Blink,代码行数:59,代码来源:v8_methods.py

示例13: v8_set_return_value

def v8_set_return_value(interface_name, method, cpp_value, for_main_world=False):
    idl_type = method.idl_type
    extended_attributes = method.extended_attributes
    if idl_type.name == 'void':
        return None

    release = False
    # [CallWith=ScriptState|NewScriptState], [RaisesException]
    if (has_extended_attribute_value(method, 'CallWith', 'ScriptState') or
        has_extended_attribute_value(method, 'CallWith', 'NewScriptState') or
        'RaisesException' in extended_attributes or
        idl_type.is_union_type):
        cpp_value = 'result'  # use local variable for value
        release = idl_type.release

    script_wrappable = 'impl' if inherits_interface(interface_name, 'Node') else ''
    return idl_type.v8_set_return_value(cpp_value, extended_attributes, script_wrappable=script_wrappable, release=release, for_main_world=for_main_world)
开发者ID:jeremyroman,项目名称:blink,代码行数:17,代码来源:v8_methods.py

示例14: v8_set_return_value

def v8_set_return_value(method, cpp_value):
    idl_type = method.idl_type
    if idl_type == 'void':
        return None
    # [CallWith=ScriptState]
    if has_extended_attribute_value(method, 'CallWith', 'ScriptState'):
        cpp_value = 'result'  # use local variable for value
    return v8_types.v8_set_return_value(idl_type, cpp_value, method.extended_attributes)
开发者ID:Metrological,项目名称:chromium,代码行数:8,代码来源:v8_methods.py

示例15: cpp_value

def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        idl_type = argument.idl_type
        if idl_type.name == 'EventListener':
            return argument.name
        if (idl_type.name in ['NodeFilter', 'NodeFilterOrNull',
                              'XPathNSResolver', 'XPathNSResolverOrNull']):
            # FIXME: remove this special case
            return '%s.release()' % argument.name
        return argument.name

    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    cpp_arguments = []
    if 'ImplementedInPrivateScript' in method.extended_attributes:
        cpp_arguments.append('toLocalFrame(toFrameIfNotDetached(info.GetIsolate()->GetCurrentContext()))')
        cpp_arguments.append('impl')

    if method.is_constructor:
        call_with_values = interface.extended_attributes.get('ConstructorCallWith')
    else:
        call_with_values = method.extended_attributes.get('CallWith')
    cpp_arguments.extend(v8_utilities.call_with_arguments(call_with_values))

    # Members of IDL partial interface definitions are implemented in C++ as
    # static member functions, which for instance members (non-static members)
    # take *impl as their first argument
    if ('PartialInterfaceImplementedAs' in method.extended_attributes and
        not 'ImplementedInPrivateScript' in method.extended_attributes and
        not method.is_static):
        cpp_arguments.append('*impl')
    cpp_arguments.extend(cpp_argument(argument) for argument in arguments)

    if 'ImplementedInPrivateScript' in method.extended_attributes:
        if method.idl_type.name != 'void':
            cpp_arguments.append('&result')
    elif ('RaisesException' in method.extended_attributes or
        (method.is_constructor and
         has_extended_attribute_value(interface, 'RaisesException', 'Constructor'))):
        cpp_arguments.append('exceptionState')

    # If a method returns an IDL dictionary or union type, the return value is
    # passed as an argument to impl classes.
    idl_type = method.idl_type
    if idl_type and idl_type.use_output_parameter_for_result:
        cpp_arguments.append('result')

    if method.name == 'Constructor':
        base_name = 'create'
    elif method.name == 'NamedConstructor':
        base_name = 'createForJSConstructor'
    elif 'ImplementedInPrivateScript' in method.extended_attributes:
        base_name = '%sMethod' % method.name
    else:
        base_name = v8_utilities.cpp_name(method)

    cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
    return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
开发者ID:dstockwell,项目名称:blink,代码行数:58,代码来源:v8_methods.py


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