本文整理汇总了Python中dart_utilities.DartUtilities.cpp_name方法的典型用法代码示例。如果您正苦于以下问题:Python DartUtilities.cpp_name方法的具体用法?Python DartUtilities.cpp_name怎么用?Python DartUtilities.cpp_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dart_utilities.DartUtilities
的用法示例。
在下文中一共展示了DartUtilities.cpp_name方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setter_expression
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import cpp_name [as 别名]
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))
示例2: property_setter
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import cpp_name [as 别名]
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
示例3: property_getter
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import cpp_name [as 别名]
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
示例4: property_getter
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import cpp_name [as 别名]
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
示例5: cpp_value
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import cpp_name [as 别名]
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))
示例6: setter_callback_name
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import cpp_name [as 别名]
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)
示例7: property_setter
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import cpp_name [as 别名]
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
示例8: interface_context
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import cpp_name [as 别名]
def interface_context(interface):
context = v8_interface.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(dart_types.includes_for_interface(parent_interface))
extended_attributes = interface.extended_attributes
if inherits_interface(interface.name, 'EventTarget'):
includes.update(['bindings/dart_event_listener.h'])
# [SetWrapperReferenceTo]
set_wrapper_reference_to_list = [{
'name': argument.name,
# FIXME: properly should be:
# 'cpp_type': argument.idl_type.cpp_type_args(used_as_rvalue_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,
} 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()
context.update({
'cpp_class': DartUtilities.cpp_name(interface),
'header_includes': header_includes,
'set_wrapper_reference_to_list': set_wrapper_reference_to_list,
'dart_class': dart_types.dart_type(interface.name),
})
# Constructors
constructors = [constructor_context(interface, constructor)
for constructor in interface.constructors
# FIXME: shouldn't put named constructors with constructors
# (currently needed for Perl compatibility)
# Handle named constructors separately
if constructor.name == 'Constructor']
if len(constructors) > 1:
context.update({'constructor_overloads': overloads_context(constructors)})
# [CustomConstructor]
custom_constructors = [custom_constructor_context(interface, constructor)
for constructor in interface.custom_constructors]
# [NamedConstructor]
named_constructor = generate_named_constructor(interface)
generate_method_native_entries(interface, constructors, 'Constructor')
generate_method_native_entries(interface, custom_constructors, 'Constructor')
if named_constructor:
generate_method_native_entries(interface, [named_constructor],
'Constructor')
event_constructor = None
if context['has_event_constructor']:
event_constructor = {
'native_entries': [
DartUtilities.generate_native_entry(
interface.name, None, 'Constructor', False, 2)],
}
if (context['constructors'] or custom_constructors or context['has_event_constructor'] or
named_constructor):
includes.add('core/frame/LocalDOMWindow.h')
context.update({
'constructors': constructors,
'custom_constructors': custom_constructors,
'event_constructor': event_constructor,
'has_custom_constructor': bool(custom_constructors),
'interface_length':
v8_interface.interface_length(interface, constructors + custom_constructors),
'is_constructor_call_with_document': DartUtilities.has_extended_attribute_value(
interface, 'ConstructorCallWith', 'Document'), # [ConstructorCallWith=Document]
'is_constructor_call_with_execution_context': DartUtilities.has_extended_attribute_value(
interface, 'ConstructorCallWith', 'ExecutionContext'), # [ConstructorCallWith=ExeuctionContext]
'named_constructor': named_constructor,
})
# Attributes
attributes = [dart_attributes.attribute_context(interface, attribute)
for attribute in interface.attributes
if not v8_attributes.is_constructor_attribute(attribute)]
context.update({
'attributes': attributes,
'has_constructor_attributes': any(attribute['constructor_type'] for attribute in attributes),
'has_replaceable_attributes': any(attribute['is_replaceable'] for attribute in attributes),
})
# Methods
methods = [dart_methods.method_context(interface, method)
for method in interface.operations
# Skip anonymous special operations (methods name empty).
if (method.name and
# detect unnamed getters from v8_interface.
#.........这里部分代码省略.........
示例9: interface_context
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import cpp_name [as 别名]
def interface_context(interface):
context = v8_interface.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(dart_types.includes_for_interface(parent_interface))
extended_attributes = interface.extended_attributes
if inherits_interface(interface.name, "EventTarget"):
includes.update(["bindings/dart_event_listener.h"])
# [SetWrapperReferenceTo]
set_wrapper_reference_to_list = [
{
"name": argument.name,
# FIXME: properly should be:
# 'cpp_type': argument.idl_type.cpp_type_args(used_as_rvalue_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,
}
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()
context.update(
{
"cpp_class": DartUtilities.cpp_name(interface),
"header_includes": header_includes,
"set_wrapper_reference_to_list": set_wrapper_reference_to_list,
"dart_class": dart_types.dart_type(interface.name),
}
)
# Constructors
constructors = [
constructor_context(interface, constructor)
for constructor in interface.constructors
# FIXME: shouldn't put named constructors with constructors
# (currently needed for Perl compatibility)
# Handle named constructors separately
if constructor.name == "Constructor"
]
if len(constructors) > 1:
context.update({"constructor_overloads": overloads_context(constructors)})
# [CustomConstructor]
custom_constructors = [
custom_constructor_context(interface, constructor) for constructor in interface.custom_constructors
]
# [NamedConstructor]
named_constructor = generate_named_constructor(interface)
generate_method_native_entries(interface, constructors, "Constructor")
generate_method_native_entries(interface, custom_constructors, "Constructor")
if named_constructor:
generate_method_native_entries(interface, [named_constructor], "Constructor")
event_constructor = None
if context["has_event_constructor"]:
event_constructor = {
"native_entries": [DartUtilities.generate_native_entry(interface.name, None, "Constructor", False, 2)]
}
context.update(
{
"constructors": constructors,
"custom_constructors": custom_constructors,
"event_constructor": event_constructor,
"has_custom_constructor": bool(custom_constructors),
"interface_length": v8_interface.interface_length(interface, constructors + custom_constructors),
"is_constructor_call_with_execution_context": DartUtilities.has_extended_attribute_value(
interface, "ConstructorCallWith", "ExecutionContext"
), # [ConstructorCallWith=ExeuctionContext]
"named_constructor": named_constructor,
}
)
# Attributes
attributes = [
dart_attributes.attribute_context(interface, attribute)
for attribute in interface.attributes
if not v8_attributes.is_constructor_attribute(attribute)
]
context.update(
{
"attributes": attributes,
"has_constructor_attributes": any(attribute["constructor_type"] for attribute in attributes),
"has_replaceable_attributes": any(attribute["is_replaceable"] for attribute in attributes),
}
)
# Methods
#.........这里部分代码省略.........