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


Python v8_utilities.cpp_name函数代码示例

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


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

示例1: setter_base_name

def setter_base_name(interface, attribute, arguments):
    if "ImplementedInPrivateScript" in attribute.extended_attributes:
        return "%sAttributeSetter" % uncapitalize(cpp_name(attribute))

    if "Reflect" not in attribute.extended_attributes:
        return "set%s" % capitalize(cpp_name(attribute))
    arguments.append(scoped_content_attribute_name(interface, attribute))

    base_idl_type = attribute.idl_type.base_type
    if base_idl_type in CONTENT_ATTRIBUTE_SETTER_NAMES:
        return CONTENT_ATTRIBUTE_SETTER_NAMES[base_idl_type]
    return "setAttribute"
开发者ID:howardroark2018,项目名称:chromium,代码行数:12,代码来源:v8_attributes.py

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

示例3: cpp_value

def cpp_value(interface, method, number_of_arguments):
    def cpp_argument(argument):
        idl_type = argument.idl_type
        if (v8_types.is_callback_interface(idl_type) or
            idl_type in ['NodeFilter', 'XPathNSResolver']):
            # 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 = v8_utilities.call_with_arguments(method)
    if ('ImplementedBy' in method.extended_attributes and
        not method.is_static):
        cpp_arguments.append('imp')
    cpp_arguments.extend(cpp_argument(argument) for argument in arguments)
    this_union_arguments = union_arguments(method.idl_type)
    if this_union_arguments:
        cpp_arguments.extend(this_union_arguments)

    if 'RaisesException' in method.extended_attributes:
        cpp_arguments.append('exceptionState')

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

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

示例5: setter_expression

def setter_expression(interface, attribute, contents):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(attribute, extended_attributes.get('SetterCallWith'))

    this_setter_base_name = setter_base_name(interface, attribute, arguments)
    setter_name = scoped_name(interface, attribute, this_setter_base_name)

    # 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 extended_attributes and
        not attribute.is_static):
        arguments.append('*impl')
    idl_type = attribute.idl_type
    if idl_type.base_type == 'EventHandler':
        getter_name = scoped_name(interface, attribute, cpp_name(attribute))
        contents['event_handler_getter_expression'] = '%s(%s)' % (
            getter_name, ', '.join(arguments))
        if (interface.name in ['Window', 'WorkerGlobalScope'] and
            attribute.name == 'onerror'):
            includes.add('bindings/v8/V8ErrorHandler.h')
            arguments.append('V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(v8Value, true, info.GetIsolate())')
        else:
            arguments.append('V8EventListenerList::getEventListener(v8Value, true, ListenerFindOrCreate)')
    elif idl_type.is_interface_type and not idl_type.array_type:
        # FIXME: should be able to eliminate WTF::getPtr in most or all cases
        arguments.append('WTF::getPtr(cppValue)')
    else:
        arguments.append('cppValue')
    if contents['is_setter_raises_exception']:
        arguments.append('exceptionState')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
开发者ID:TheTypoMaster,项目名称:evita,代码行数:33,代码来源:v8_attributes.py

示例6: dictionary_impl_context

def dictionary_impl_context(dictionary, interfaces_info):
    def remove_duplicate_members(members):
        # When [ImplementedAs] is used, cpp_name can conflict. For example,
        # dictionary D { long foo; [ImplementedAs=foo, DeprecateAs=Foo] long oldFoo; };
        # This function removes such duplications, checking they have the same type.
        members_dict = {}
        for member in members:
            cpp_name = member['cpp_name']
            duplicated_member = members_dict.get(cpp_name)
            if duplicated_member and duplicated_member != member:
                raise Exception('Member name conflict: %s' % cpp_name)
            members_dict[cpp_name] = member
        return sorted(members_dict.values(), key=lambda member: member['cpp_name'])

    includes.clear()
    header_includes = set(['platform/heap/Handle.h'])
    members = [member_impl_context(member, interfaces_info, header_includes)
               for member in dictionary.members]
    members = remove_duplicate_members(members)
    context = {
        'header_includes': header_includes,
        'cpp_class': v8_utilities.cpp_name(dictionary),
        'members': members,
    }
    if dictionary.parent:
        context['parent_cpp_class'] = v8_utilities.cpp_name_from_interfaces_info(
            dictionary.parent, interfaces_info)
        parent_interface_info = interfaces_info.get(dictionary.parent)
        if parent_interface_info:
            context['header_includes'].add(
                parent_interface_info['include_path'])
    return context
开发者ID:joone,项目名称:blink-crosswalk,代码行数:32,代码来源:v8_dictionary.py

示例7: dictionary_context

def dictionary_context(dictionary, interfaces_info):
    includes.clear()
    includes.update(DICTIONARY_CPP_INCLUDES)

    members = [member_context(dictionary, member)
               for member in sorted(dictionary.members,
                                    key=operator.attrgetter('name'))]

    for member in members:
        if member['runtime_enabled_function']:
            includes.add('platform/RuntimeEnabledFeatures.h')
            break

    cpp_class = v8_utilities.cpp_name(dictionary)
    context = {
        'cpp_class': cpp_class,
        'header_includes': set(DICTIONARY_H_INCLUDES),
        'members': members,
        'required_member_names': sorted([member.name
                                         for member in dictionary.members
                                         if member.is_required]),
        'use_permissive_dictionary_conversion': 'PermissiveDictionaryConversion' in dictionary.extended_attributes,
        'v8_class': v8_types.v8_type(cpp_class),
        'v8_original_class': v8_types.v8_type(dictionary.name),
    }
    if dictionary.parent:
        IdlType(dictionary.parent).add_includes_for_type()
        parent_cpp_class = v8_utilities.cpp_name_from_interfaces_info(
            dictionary.parent, interfaces_info)
        context.update({
            'parent_cpp_class': parent_cpp_class,
            'parent_v8_class': v8_types.v8_type(parent_cpp_class),
        })
    return context
开发者ID:endlessm,项目名称:chromium-browser,代码行数:34,代码来源:v8_dictionary.py

示例8: member_context

def member_context(member):
    idl_type = member.idl_type
    idl_type.add_includes_for_type()
    idl_type = unwrap_nullable_if_needed(idl_type)

    def default_values():
        if not member.default_value:
            return None, None
        if member.default_value.is_null:
            return None, 'v8::Null(isolate)'
        cpp_default_value = str(member.default_value)
        v8_default_value = idl_type.cpp_value_to_v8_value(
            cpp_value=cpp_default_value, isolate='isolate',
            creation_context='creationContext')
        return cpp_default_value, v8_default_value

    cpp_default_value, v8_default_value = default_values()
    cpp_name = v8_utilities.cpp_name(member)

    return {
        'cpp_default_value': cpp_default_value,
        'cpp_name': cpp_name,
        'cpp_type': idl_type.cpp_type,
        'cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
            cpp_value='impl.%s()' % cpp_name, isolate='isolate',
            creation_context='creationContext',
            extended_attributes=member.extended_attributes),
        'enum_validation_expression': idl_type.enum_validation_expression,
        'has_method_name': has_method_name_for_dictionary_member(member),
        'is_object': idl_type.name == 'Object',
        'name': member.name,
        'setter_name': setter_name_for_dictionary_member(member),
        'v8_default_value': v8_default_value,
    }
开发者ID:syncfusion,项目名称:SfQtWebKit,代码行数:34,代码来源:v8_dictionary.py

示例9: setter_expression

def setter_expression(interface, attribute, contents):
    extended_attributes = attribute.extended_attributes
    arguments = v8_utilities.call_with_arguments(attribute, extended_attributes.get('SetterCallWith'))

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

    if ('ImplementedBy' in extended_attributes and
        not attribute.is_static):
        arguments.append('imp')
    idl_type = attribute.idl_type
    if idl_type == 'EventHandler':
        getter_name = v8_utilities.scoped_name(interface, attribute, cpp_name(attribute))
        contents['event_handler_getter_expression'] = '%s(%s)' % (
            getter_name, ', '.join(arguments))
        if (interface.name in ['Window', 'WorkerGlobalScope'] and
            attribute.name == 'onerror'):
            includes.add('bindings/v8/V8ErrorHandler.h')
            arguments.append('V8EventListenerList::findOrCreateWrapper<V8ErrorHandler>(jsValue, true, info.GetIsolate())')
        else:
            arguments.append('V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate)')
    elif v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_type):
        # FIXME: should be able to eliminate WTF::getPtr in most or all cases
        arguments.append('WTF::getPtr(cppValue)')
    else:
        arguments.append('cppValue')
    if contents['is_setter_raises_exception']:
        arguments.append('exceptionState')

    return '%s(%s)' % (setter_name, ', '.join(arguments))
开发者ID:glenkim-dev,项目名称:blink-crosswalk,代码行数:30,代码来源:v8_attributes.py

示例10: __init__

    def __init__(self, definitions, interface_name, output_directory, relative_dir_posix, idl_directories, verbose=False):
        self.idl_definitions = definitions
        self.interface_name = interface_name
        self.idl_directories = idl_directories
        self.output_directory = output_directory
        self.verbose = verbose
        # FIXME: remove definitions check when remove write_dummy_header_and_cpp
        if not definitions:
            return
        try:
            self.interface = definitions.interfaces[interface_name]
        except KeyError:
            raise Exception('%s not in IDL definitions' % interface_name)
        if self.interface.is_callback:
            header_template_filename = 'callback_interface.h'
            cpp_template_filename = 'callback_interface.cpp'
            self.generate_contents = v8_callback_interface.generate_callback_interface
        else:
            header_template_filename = 'interface.h'
            cpp_template_filename = 'interface.cpp'
            self.generate_contents = v8_interface.generate_interface
        jinja_env = jinja2.Environment(
            loader=jinja2.FileSystemLoader(templates_dir),
            keep_trailing_newline=True,  # newline-terminate generated files
            lstrip_blocks=True,  # so can indent control flow tags
            trim_blocks=True)
        jinja_env.filters['conditional'] = conditional_if_endif
        self.header_template = jinja_env.get_template(header_template_filename)
        self.cpp_template = jinja_env.get_template(cpp_template_filename)

        class_name = cpp_name(self.interface)
        self.include_for_cpp_class = posixpath.join(relative_dir_posix, class_name + '.h')
        enumerations = definitions.enumerations
        if enumerations:
            v8_types.set_enum_types(enumerations)
开发者ID:chunywang,项目名称:blink-crosswalk,代码行数:35,代码来源:code_generator_v8.py

示例11: generate_code_internal

 def generate_code_internal(self, definitions, definition_name):
     if not definition_name in definitions.dictionaries:
         raise ValueError('%s is not an IDL dictionary')
     interfaces_info = self.info_provider.interfaces_info
     dictionary = definitions.dictionaries[definition_name]
     interface_info = interfaces_info[definition_name]
     header_template = self.jinja_env.get_template('dictionary_impl.h')
     cpp_template = self.jinja_env.get_template('dictionary_impl.cpp')
     template_context = v8_dictionary.dictionary_impl_context(
         dictionary, interfaces_info)
     include_paths = interface_info.get('dependencies_include_paths')
     # Add union containers header file to header_includes rather than
     # cpp file so that union containers can be used in dictionary headers.
     union_container_headers = [header for header in include_paths
                                if header.find('UnionTypes') > 0]
     include_paths = [header for header in include_paths
                      if header not in union_container_headers]
     template_context['header_includes'].update(union_container_headers)
     if not is_testing_target(interface_info.get('full_path')):
         template_context['exported'] = self.info_provider.specifier_for_export
         template_context['header_includes'].add(self.info_provider.include_path_for_export)
     header_text, cpp_text = render_template(
         include_paths, header_template, cpp_template, template_context)
     header_path, cpp_path = self.output_paths(
         cpp_name(dictionary), interface_info)
     return (
         (header_path, header_text),
         (cpp_path, cpp_text),
     )
开发者ID:b-cuts,项目名称:blink-crosswalk,代码行数:29,代码来源:code_generator_v8.py

示例12: generate_interface

def generate_interface(interface):
    includes.clear()
    includes.update(INTERFACE_CPP_INCLUDES)
    v8_class_name = v8_utilities.v8_class_name(interface)

    template_contents = {
        'cpp_class_name': cpp_name(interface),
        'header_includes': INTERFACE_H_INCLUDES,
        'interface_name': interface.name,
        'v8_class_name': v8_class_name,
    }

    template_contents.update({
        'constants': [generate_constant(constant) for constant in interface.constants],
        'do_not_check_constants': 'DoNotCheckConstants' in interface.extended_attributes,
    })

    attributes = [v8_attributes.generate_attribute(interface, attribute)
                  for attribute in interface.attributes]
    template_contents.update({
        'attributes': attributes,
        'has_constructor_attributes': any(attribute['is_constructor'] for attribute in attributes),
        'has_per_context_enabled_attributes': any(attribute['per_context_enabled_function_name'] for attribute in attributes),
        'has_replaceable_attributes': any(attribute['is_replaceable'] for attribute in attributes),
        'has_runtime_enabled_attributes': any(attribute['runtime_enabled_function_name'] for attribute in attributes),
    })

    template_contents['methods'] = [v8_methods.generate_method(method)
                                    for method in interface.operations]

    return template_contents
开发者ID:chunywang,项目名称:blink-crosswalk,代码行数:31,代码来源:v8_interface.py

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

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

示例15: dictionary_impl_context

def dictionary_impl_context(dictionary, interfaces_info):
    includes.clear()
    header_includes = set(["platform/heap/Handle.h"])
    return {
        "header_includes": header_includes,
        "cpp_class": v8_utilities.cpp_name(dictionary),
        "members": [member_impl_context(member, interfaces_info, header_includes) for member in dictionary.members],
    }
开发者ID:wulala-wuwu,项目名称:Blink,代码行数:8,代码来源:v8_dictionary.py


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