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


Python dart_utilities.DartUtilities类代码示例

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


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

示例1: setter_expression

def setter_expression(interface, attribute, context):
    extended_attributes = attribute.extended_attributes
    arguments = DartUtilities.call_with_arguments(
        extended_attributes.get('SetterCallWith') or
        extended_attributes.get('CallWith'))

    this_setter_base_name = v8_attributes.setter_base_name(interface, attribute, arguments)
    setter_name = DartUtilities.scoped_name(interface, attribute, this_setter_base_name)

    if ('PartialInterfaceImplementedAs' in extended_attributes and
        not attribute.is_static):
        arguments.append('*receiver')
    idl_type = attribute.idl_type
    if idl_type.base_type == 'EventHandler':
        getter_name = DartUtilities.scoped_name(interface, attribute, DartUtilities.cpp_name(attribute))
        context['event_handler_getter_expression'] = '%s(%s)' % (
            getter_name, ', '.join(arguments))
        # FIXME(vsm): Do we need to support this? If so, what's our analogue of
        # V8EventListenerList?
        arguments.append('nullptr')
    else:
        attribute_name = dart_types.check_reserved_name(attribute.name)
        arguments.append(attribute_name)
    if context['is_setter_raises_exception']:
        arguments.append('es')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
开发者ID:Jamesducque,项目名称:mojo,代码行数:27,代码来源:dart_attributes.py

示例2: attribute_context

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,代码行数:59,代码来源:dart_attributes.py

示例3: method_context

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,代码行数:57,代码来源:dart_methods.py

示例4: cpp_value

def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        argument_name = dart_types.check_reserved_name(argument.name)
        idl_type = argument.idl_type

        if idl_type.is_typed_array_type:
            return '%s.get()' % argument_name

        # TODO(eseidel): This should check cpp_type.endswith('Handle')
        if idl_type.name == 'MojoDataPipeConsumer':
            return '%s.Pass()' % argument_name

        if idl_type.name == 'EventListener':
            if (interface.name == 'EventTarget' and
                method.name == 'removeEventListener'):
                # FIXME: remove this special case by moving get() into
                # EventTarget::removeEventListener
                return '%s.get()' % argument_name
            return argument.name
        if idl_type.is_callback_interface:
            return '%s.release()' % argument_name
        return argument_name

    # Truncate omitted optional arguments
    arguments = method.arguments[:number_of_arguments]
    if method.is_constructor:
        call_with_values = interface.extended_attributes.get('ConstructorCallWith')
    else:
        call_with_values = method.extended_attributes.get('CallWith')
    cpp_arguments = DartUtilities.call_with_arguments(call_with_values)
    if ('PartialInterfaceImplementedAs' in method.extended_attributes and not method.is_static):
        cpp_arguments.append('*receiver')

    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 ('RaisesException' in method.extended_attributes or
        (method.is_constructor and
         DartUtilities.has_extended_attribute_value(interface, 'RaisesException', 'Constructor'))):
        cpp_arguments.append('es')

    if method.name == 'Constructor':
        base_name = 'create'
    elif method.name == 'NamedConstructor':
        base_name = 'createForJSConstructor'
    else:
        base_name = DartUtilities.cpp_name(method)
    cpp_method_name = DartUtilities.scoped_name(interface, method, base_name)
    return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
开发者ID:Miaque,项目名称:mojo,代码行数:52,代码来源:dart_methods.py

示例5: generate_method_native_entry

def generate_method_native_entry(interface, method, count, kind):
    name = method.get('name')
    is_static = bool(method.get('is_static'))
    native_entry = \
        DartUtilities.generate_native_entry(interface.name, name,
                                            kind, is_static, count)
    return native_entry
开发者ID:Jamesducque,项目名称:mojo,代码行数:7,代码来源:dart_interface.py

示例6: add

 def add(prop, name, arity):
     if context[prop]:
         if "native_entries" not in context[prop]:
             context[prop].update({"native_entries": []})
         context[prop]["native_entries"].append(
             DartUtilities.generate_native_entry(interface.name, name, "Method", False, arity)
         )
开发者ID:MitchRudominer,项目名称:engine,代码行数:7,代码来源:dart_interface.py

示例7: add

 def add(prop, name, arity):
     if context[prop]:
         if 'native_entries' not in context[prop]:
             context[prop].update({'native_entries': []})
         context[prop]['native_entries'].append(
             DartUtilities.generate_native_entry(
                 interface.name, name, 'Method', False, arity))
开发者ID:Jamesducque,项目名称:mojo,代码行数:7,代码来源:dart_interface.py

示例8: property_setter

def property_setter(setter, cpp_arguments):
    context = v8_interface.property_setter(setter)

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

    cpp_method_name = 'receiver->%s' % DartUtilities.cpp_name(setter)

    if is_raises_exception:
        cpp_arguments.append('es')

    cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
    context.update({
        'cpp_type': idl_type.cpp_type,
        'cpp_value': cpp_value,
        'is_raises_exception': is_raises_exception,
        'name': DartUtilities.cpp_name(setter)})
    return context
开发者ID:Jamesducque,项目名称:mojo,代码行数:19,代码来源:dart_interface.py

示例9: setter_expression

def setter_expression(interface, attribute, context):
    extended_attributes = attribute.extended_attributes
    arguments = DartUtilities.call_with_arguments(
        extended_attributes.get('SetterCallWith') or
        extended_attributes.get('CallWith'))

    this_setter_base_name = v8_attributes.setter_base_name(interface, attribute, arguments)
    setter_name = DartUtilities.scoped_name(interface, attribute, this_setter_base_name)

    if ('PartialInterfaceImplementedAs' in extended_attributes and
        not attribute.is_static):
        arguments.append('*receiver')
    idl_type = attribute.idl_type
    attribute_name = dart_types.check_reserved_name(attribute.name)
    arguments.append(attribute_name)
    if context['is_setter_raises_exception']:
        arguments.append('es')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
开发者ID:MitchRudominer,项目名称:engine,代码行数:19,代码来源:dart_attributes.py

示例10: getter_expression

def getter_expression(interface, attribute, context):
    v8_attributes.getter_expression(interface, attribute, context)

    arguments = []
    this_getter_base_name = v8_attributes.getter_base_name(interface, attribute, arguments)
    getter_name = DartUtilities.scoped_name(interface, attribute, this_getter_base_name)

    arguments.extend(DartUtilities.call_with_arguments(
        attribute.extended_attributes.get('CallWith')))
    if ('PartialInterfaceImplementedAs' in attribute.extended_attributes and
        not attribute.is_static):
        # Pass by reference.
        arguments.append('*receiver')

    if attribute.idl_type.is_explicit_nullable:
        arguments.append('is_null')
    if context['is_getter_raises_exception']:
        arguments.append('es')
    return '%s(%s)' % (getter_name, ', '.join(arguments))
开发者ID:MitchRudominer,项目名称:engine,代码行数:19,代码来源:dart_attributes.py

示例11: property_getter

def property_getter(getter, cpp_arguments):
    def is_null_expression(idl_type):
        if idl_type.is_union_type:
            return " && ".join("!result%sEnabled" % i for i, _ in enumerate(idl_type.member_types))
        if idl_type.name == "String":
            # FIXME(vsm): This looks V8 specific.
            return "result.isNull()"
        if idl_type.is_interface_type:
            return "!result"
        return ""

    context = v8_interface.property_getter(getter, [])

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

    # FIXME: make more generic, so can use dart_methods.cpp_value
    cpp_method_name = "receiver->%s" % DartUtilities.cpp_name(getter)

    if is_raises_exception:
        cpp_arguments.append("es")
    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))

    context.update(
        {
            "cpp_type": idl_type.cpp_type,
            "cpp_value": cpp_value,
            "is_null_expression": is_null_expression(idl_type),
            "is_raises_exception": is_raises_exception,
            "name": DartUtilities.cpp_name(getter),
            "union_arguments": union_arguments,
            "dart_set_return_value": idl_type.dart_set_return_value(
                "result", extended_attributes=extended_attributes, script_wrappable="receiver", release=idl_type.release
            ),
        }
    )
    return context
开发者ID:MitchRudominer,项目名称:engine,代码行数:42,代码来源:dart_interface.py

示例12: property_getter

def property_getter(getter, cpp_arguments):
    def is_null_expression(idl_type):
        if idl_type.is_union_type:
            return ' && '.join('!result%sEnabled' % i
                               for i, _ in enumerate(idl_type.member_types))
        if idl_type.name == 'String':
            # FIXME(vsm): This looks V8 specific.
            return 'result.isNull()'
        if idl_type.is_interface_type:
            return '!result'
        return ''

    context = v8_interface.property_getter(getter, [])

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

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

    if is_raises_exception:
        cpp_arguments.append('es')
    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))

    context.update({
        'cpp_type': idl_type.cpp_type,
        'cpp_value': cpp_value,
        'is_null_expression': is_null_expression(idl_type),
        'is_raises_exception': is_raises_exception,
        'name': DartUtilities.cpp_name(getter),
        'union_arguments': union_arguments,
        'dart_set_return_value': idl_type.dart_set_return_value('result',
                                                                extended_attributes=extended_attributes,
                                                                script_wrappable='receiver',
                                                                release=idl_type.release)})
    return context
开发者ID:Jamesducque,项目名称:mojo,代码行数:42,代码来源:dart_interface.py

示例13: dart_value_to_cpp_value

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,代码行数:53,代码来源:dart_types.py

示例14: property_setter

def property_setter(setter, cpp_arguments):
    context = v8_interface.property_setter(setter)

    idl_type = setter.idl_type
    extended_attributes = setter.extended_attributes
    is_raises_exception = "RaisesException" in extended_attributes

    cpp_method_name = "receiver->%s" % DartUtilities.cpp_name(setter)

    if is_raises_exception:
        cpp_arguments.append("es")

    cpp_value = "%s(%s)" % (cpp_method_name, ", ".join(cpp_arguments))
    context.update(
        {
            "cpp_type": idl_type.cpp_type,
            "cpp_value": cpp_value,
            "is_raises_exception": is_raises_exception,
            "name": DartUtilities.cpp_name(setter),
        }
    )
    return context
开发者ID:MitchRudominer,项目名称:engine,代码行数:22,代码来源:dart_interface.py

示例15: setter_callback_name

def setter_callback_name(interface, attribute):
    cpp_class_name = DartUtilities.cpp_name(interface)
    extended_attributes = attribute.extended_attributes
    if (('Replaceable' in extended_attributes and
         'PutForwards' not in extended_attributes) or
        v8_attributes.is_constructor_attribute(attribute)):
        # FIXME: rename to ForceSetAttributeOnThisCallback, since also used for Constructors
        return '{0}V8Internal::{0}ReplaceableAttributeSetterCallback'.format(cpp_class_name)
    # FIXME:disabling PutForwards for now since we didn't support it before
    #    if attribute.is_read_only and 'PutForwards' not in extended_attributes:
    if attribute.is_read_only:
        return '0'
    return '%sV8Internal::%sAttributeSetterCallback' % (cpp_class_name, attribute.name)
开发者ID:MitchRudominer,项目名称:engine,代码行数:13,代码来源:dart_attributes.py


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