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


Python DartUtilities.bool_to_cpp方法代码示例

本文整理汇总了Python中dart_utilities.DartUtilities.bool_to_cpp方法的典型用法代码示例。如果您正苦于以下问题:Python DartUtilities.bool_to_cpp方法的具体用法?Python DartUtilities.bool_to_cpp怎么用?Python DartUtilities.bool_to_cpp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dart_utilities.DartUtilities的用法示例。


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

示例1: attribute_context

# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import bool_to_cpp [as 别名]
def attribute_context(interface, attribute):
    # Call v8's implementation.
    context = v8_attributes.attribute_context(interface, attribute)

    extended_attributes = attribute.extended_attributes

    # Augment's Dart's information to context.
    idl_type = attribute.idl_type
    base_idl_type = idl_type.base_type
    # TODO(terry): Work around for DOMString[] base should be IDLTypeArray
    if base_idl_type == None:
        # Returns Array or Sequence.
        base_idl_type = idl_type.inner_name

    # [Custom]
    has_custom_getter = ('Custom' in extended_attributes and
                          extended_attributes['Custom'] in [None, 'Getter'])
    has_custom_setter = (not attribute.is_read_only and
                         (('Custom' in extended_attributes and
                          extended_attributes['Custom'] in [None, 'Setter'])))

    is_call_with_script_state = DartUtilities.has_extended_attribute_value(attribute, 'CallWith', 'ScriptState')

    is_auto_scope = not 'DartNoAutoScope' in extended_attributes

    context.update({
      'has_custom_getter': has_custom_getter,
      'has_custom_setter': has_custom_setter,
      'is_auto_scope': is_auto_scope,   # Used internally (outside of templates).
      'is_call_with_script_state': is_call_with_script_state,
      'auto_scope': DartUtilities.bool_to_cpp(is_auto_scope),
      'dart_type': dart_types.idl_type_to_dart_type(idl_type),
    })

    if v8_attributes.is_constructor_attribute(attribute):
        v8_attributes.constructor_getter_context(interface, attribute, context)
        return context
    if not v8_attributes.has_custom_getter(attribute):
        getter_context(interface, attribute, context)
    if (not attribute.is_read_only):
        # FIXME: We did not previously support the PutForwards attribute, so I am
        # disabling it here for now to get things compiling.
        # We may wish to revisit this.
        # if (not has_custom_setter(attribute) and
        # (not attribute.is_read_only or 'PutForwards' in extended_attributes)):
        setter_context(interface, attribute, context)

    native_entry_getter = \
        DartUtilities.generate_native_entry(
            interface.name, attribute.name, 'Getter', attribute.is_static, 0)
    native_entry_setter = \
        DartUtilities.generate_native_entry(
            interface.name, attribute.name, 'Setter', attribute.is_static, 1)
    context.update({
        'native_entry_getter': native_entry_getter,
        'native_entry_setter': native_entry_setter,
    })

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

示例2: method_context

# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import bool_to_cpp [as 别名]
def method_context(interface, method):
    context = v8_methods.method_context(interface, method)

    arguments = method.arguments
    extended_attributes = method.extended_attributes
    idl_type = method.idl_type

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

    if context['is_call_with_script_state']:
        includes.add('bindings/core/dart/DartScriptState.h')

    if idl_type.union_arguments and len(idl_type.union_arguments) > 0:
        this_cpp_type = []
        for cpp_type in idl_type.member_types:
            this_cpp_type.append("RefPtr<%s>" % cpp_type)
    else:
        this_cpp_type = idl_type.cpp_type

    is_auto_scope = not 'DartNoAutoScope' in extended_attributes

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

    union_arguments = []
    if idl_type.union_arguments:
        union_arguments.extend([union_arg['cpp_value']
                                for union_arg in idl_type.union_arguments])

    is_custom = 'Custom' in extended_attributes or 'DartCustom' in extended_attributes

    context.update({
        'arguments': arguments_data,
        'cpp_type': this_cpp_type,
        'cpp_value': this_cpp_value,
        'dart_type': dart_types.idl_type_to_dart_type(idl_type),
        'dart_name': extended_attributes.get('DartName'),
        'has_exception_state':
            context['is_raises_exception'] or
            any(argument for argument in arguments
                if argument.idl_type.name == 'SerializedScriptValue' or
                   argument.idl_type.is_integer_type),
        'is_auto_scope': is_auto_scope,
        'auto_scope': DartUtilities.bool_to_cpp(is_auto_scope),
        'is_custom': is_custom,
        'is_custom_dart': 'DartCustom' in extended_attributes,
        'is_custom_dart_new': DartUtilities.has_extended_attribute_value(method, 'DartCustom', 'New'),
        # FIXME(terry): DartStrictTypeChecking no longer supported; TypeChecking is
        #               new extended attribute.
        'is_strict_type_checking':
            'DartStrictTypeChecking' in extended_attributes or
            'DartStrictTypeChecking' in interface.extended_attributes,
        'union_arguments': union_arguments,
        'dart_set_return_value': dart_set_return_value(interface.name, method, this_cpp_value),
    })
    return context
开发者ID:Jamesducque,项目名称:mojo,代码行数:59,代码来源:dart_methods.py

示例3: dart_value_to_cpp_value

# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import bool_to_cpp [as 别名]
def dart_value_to_cpp_value(idl_type, extended_attributes, variable_name,
                            null_check, has_type_checking_interface,
                            index, auto_scope=True):
    # Composite types
    native_array_element_type = idl_type.native_array_element_type
    if native_array_element_type:
        return dart_value_to_cpp_value_array_or_sequence(native_array_element_type, variable_name, index)

    # Simple types
    idl_type = idl_type.preprocessed_type
    add_includes_for_type(idl_type)
    base_idl_type = idl_type.base_type
    implemented_as = idl_type.implemented_as

    if 'EnforceRange' in extended_attributes:
        arguments = ', '.join([variable_name, 'EnforceRange', 'exceptionState'])
    elif idl_type.is_integer_type:  # NormalConversion
        arguments = ', '.join([variable_name, 'es'])
    else:
        arguments = variable_name

    if base_idl_type in CPP_SPECIAL_CONVERSION_RULES:
        implemented_as = CPP_SPECIAL_CONVERSION_RULES[base_idl_type]

    if base_idl_type in DART_TO_CPP_VALUE:
        cpp_expression_format = DART_TO_CPP_VALUE[base_idl_type]
    elif idl_type.is_typed_array_type:
        # FIXME(vsm): V8 generates a type check here as well. Do we need one?
        # FIXME(vsm): When do we call the externalized version? E.g., see
        # bindings/dart/custom/DartWaveShaperNodeCustom.cpp - it calls
        # DartUtilities::dartToExternalizedArrayBufferView instead.
        # V8 always converts null here
        cpp_expression_format = ('DartUtilities::dartTo{idl_type}WithNullCheck(args, {index}, exception)')
    elif idl_type.is_callback_interface:
        cpp_expression_format = ('Dart{idl_type}::create{null_check}(args, {index}, exception)')
    else:
        cpp_expression_format = ('DartConverter<{implemented_as}*>::FromArguments{null_check}(args, {index}, exception)')

    # We allow the calling context to force a null check to handle
    # some cases that require calling context info.  V8 handles all
    # of this differently, and we may wish to reconsider this approach
    check_string = ''
    if null_check or allow_null(idl_type, extended_attributes,
                                has_type_checking_interface):
        check_string = 'WithNullCheck'
    elif allow_empty(idl_type, extended_attributes):
        check_string = 'WithEmptyCheck'
    return cpp_expression_format.format(null_check=check_string,
                                        arguments=arguments,
                                        index=index,
                                        idl_type=base_idl_type,
                                        implemented_as=implemented_as,
                                        auto_scope=DartUtilities.bool_to_cpp(auto_scope))
开发者ID:Miaque,项目名称:mojo,代码行数:55,代码来源:dart_types.py

示例4: dart_set_return_value

# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import bool_to_cpp [as 别名]
def dart_set_return_value(idl_type, cpp_value,
                          extended_attributes=None, script_wrappable='',
                          release=False, for_main_world=False,
                          auto_scope=True):
    """Returns a statement that converts a C++ value to a Dart value and sets it as a return value.

    """
    def dom_wrapper_conversion_type():
        if not script_wrappable:
            return 'DOMWrapperDefault'
        if for_main_world:
            return 'DOMWrapperForMainWorld'
        return 'DOMWrapperFast'

    idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, extended_attributes)
    this_dart_conversion_type = idl_type.dart_conversion_type(extended_attributes)
    # SetReturn-specific overrides
    if this_dart_conversion_type in ['Date', 'EventHandler', 'ScriptPromise', 'SerializedScriptValue', 'array']:
        # Convert value to Dart and then use general Dart_SetReturnValue
        # FIXME(vsm): Why do we differ from V8 here? It doesn't have a
        # creation_context.
        creation_context = ''
        if this_dart_conversion_type == 'array':
            # FIXME: This is not right if the base type is a primitive, DOMString, etc.
            # What is the right check for base type?
            base_type = str(idl_type.element_type)
            if base_type not in DART_TO_CPP_VALUE:
                if base_type == 'None':
                    raise Exception('Unknown base type for ' + str(idl_type))
                creation_context = '<Dart%s>' % base_type
            if idl_type.is_nullable:
                creation_context = 'Nullable' + creation_context

        cpp_value = idl_type.cpp_value_to_dart_value(cpp_value, creation_context=creation_context,
                                                     extended_attributes=extended_attributes)
    if this_dart_conversion_type == 'DOMWrapper':
        this_dart_conversion_type = dom_wrapper_conversion_type()

    format_string = DART_SET_RETURN_VALUE[this_dart_conversion_type]

    if release:
        cpp_value = '%s.release()' % cpp_value
    statement = format_string.format(cpp_value=cpp_value,
                                     implemented_as=idl_type.implemented_as,
                                     type_name=idl_type.name,
                                     script_wrappable=script_wrappable,
                                     auto_scope=DartUtilities.bool_to_cpp(auto_scope))
    return statement
开发者ID:Miaque,项目名称:mojo,代码行数:50,代码来源:dart_types.py


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