本文整理汇总了Python中dart_utilities.DartUtilities.generate_native_entry方法的典型用法代码示例。如果您正苦于以下问题:Python DartUtilities.generate_native_entry方法的具体用法?Python DartUtilities.generate_native_entry怎么用?Python DartUtilities.generate_native_entry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dart_utilities.DartUtilities
的用法示例。
在下文中一共展示了DartUtilities.generate_native_entry方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: attribute_context
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import generate_native_entry [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
示例2: add
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import generate_native_entry [as 别名]
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))
示例3: generate_method_native_entry
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import generate_native_entry [as 别名]
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
示例4: add
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import generate_native_entry [as 别名]
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)
)
示例5: interface_context
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import generate_native_entry [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.
#.........这里部分代码省略.........
示例6: interface_context
# 需要导入模块: from dart_utilities import DartUtilities [as 别名]
# 或者: from dart_utilities.DartUtilities import generate_native_entry [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
#.........这里部分代码省略.........