本文整理汇总了Python中v8_globals.includes.update函数的典型用法代码示例。如果您正苦于以下问题:Python update函数的具体用法?Python update怎么用?Python update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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
示例3: callback_function_context
def callback_function_context(callback_function):
includes.clear()
includes.update(CALLBACK_FUNCTION_CPP_INCLUDES)
idl_type = callback_function.idl_type
idl_type_str = str(idl_type)
forward_declarations = []
for argument in callback_function.arguments:
if argument.idl_type.is_interface_type:
forward_declarations.append(argument.idl_type)
argument.idl_type.add_includes_for_type(callback_function.extended_attributes)
context = {
"cpp_class": callback_function.name,
"cpp_includes": sorted(includes),
"forward_declarations": sorted(forward_declarations),
"header_includes": sorted(CALLBACK_FUNCTION_H_INCLUDES),
"idl_type": idl_type_str,
}
if idl_type_str != "void":
context.update(
{
"return_cpp_type": idl_type.cpp_type + "&",
"return_value": idl_type.v8_value_to_local_cpp_value(
callback_function.extended_attributes,
"v8ReturnValue",
"cppValue",
isolate="scriptState->isolate()",
bailout_return_value="false",
),
}
)
context.update(arguments_context(callback_function.arguments, context.get("return_cpp_type")))
return context
示例4: callback_function_context
def callback_function_context(callback_function):
includes.clear()
includes.update(CALLBACK_FUNCTION_CPP_INCLUDES)
idl_type = callback_function.idl_type
idl_type_str = str(idl_type)
forward_declarations = []
for argument in callback_function.arguments:
if argument.idl_type.is_interface_type:
forward_declarations.append(argument.idl_type)
argument.idl_type.add_includes_for_type(callback_function.extended_attributes)
context = {
'cpp_class': callback_function.name,
'cpp_includes': sorted(includes),
'forward_declarations': sorted(forward_declarations),
'header_includes': sorted(CALLBACK_FUNCTION_H_INCLUDES),
'idl_type': idl_type_str,
}
if idl_type_str != 'void':
context.update({
'return_cpp_type': idl_type.cpp_type + '&',
'return_value': idl_type.v8_value_to_local_cpp_value(
callback_function.extended_attributes,
'v8ReturnValue', 'cppValue',
isolate='m_scriptState->isolate()',
bailout_return_value='false'),
})
context.update(arguments_context(callback_function.arguments, context.get('return_cpp_type')))
return context
示例5: v8_value_to_cpp_value
def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index):
this_array_or_sequence_type = array_or_sequence_type(idl_type)
if this_array_or_sequence_type:
return v8_value_to_cpp_value_array_or_sequence(this_array_or_sequence_type, v8_value, index)
idl_type = preprocess_idl_type(idl_type)
if 'EnforceRange' in extended_attributes:
arguments = ', '.join([v8_value, 'EnforceRange', 'ok'])
else: # NormalConversion
arguments = v8_value
if idl_type in V8_VALUE_TO_CPP_VALUE_BASIC:
cpp_expression_format = V8_VALUE_TO_CPP_VALUE_BASIC[idl_type]
elif idl_type in V8_VALUE_TO_CPP_VALUE_AND_INCLUDES:
cpp_expression_format, new_includes = V8_VALUE_TO_CPP_VALUE_AND_INCLUDES[idl_type]
includes.update(new_includes)
elif is_typed_array_type(idl_type):
cpp_expression_format = (
'{v8_value}->Is{idl_type}() ? '
'V8{idl_type}::toNative(v8::Handle<v8::{idl_type}>::Cast({v8_value})) : 0')
add_includes_for_type(idl_type)
else:
cpp_expression_format = (
'V8{idl_type}::HasInstance({v8_value}, info.GetIsolate(), worldType(info.GetIsolate())) ? '
'V8{idl_type}::toNative(v8::Handle<v8::Object>::Cast({v8_value})) : 0')
add_includes_for_type(idl_type)
return cpp_expression_format.format(arguments=arguments, idl_type=idl_type, v8_value=v8_value)
示例6: callback_function_context
def callback_function_context(callback_function):
includes.clear()
includes.update(CALLBACK_FUNCTION_CPP_INCLUDES)
idl_type = callback_function.idl_type
idl_type_str = str(idl_type)
for argument in callback_function.arguments:
argument.idl_type.add_includes_for_type(
callback_function.extended_attributes)
context = {
# While both |callback_function_name| and |cpp_class| are identical at
# the moment, the two are being defined because their values may change
# in the future (e.g. if we support [ImplementedAs=] in callback
# functions).
'callback_function_name': callback_function.name,
'cpp_class': callback_function.name,
'cpp_includes': sorted(includes),
'forward_declarations': sorted(forward_declarations(callback_function)),
'header_includes': sorted(CALLBACK_FUNCTION_H_INCLUDES),
'idl_type': idl_type_str,
}
if idl_type_str != 'void':
context.update({
'return_cpp_type': idl_type.cpp_type + '&',
'return_value': idl_type.v8_value_to_local_cpp_value(
callback_function.extended_attributes,
'v8ReturnValue', 'cppValue',
isolate='script_state_->GetIsolate()',
bailout_return_value='false'),
})
context.update(arguments_context(callback_function.arguments, context.get('return_cpp_type')))
return context
示例7: callback_interface_context
def callback_interface_context(callback_interface):
includes.clear()
includes.update(CALLBACK_INTERFACE_CPP_INCLUDES)
return {
"cpp_class": callback_interface.name,
"v8_class": v8_utilities.v8_class_name(callback_interface),
"header_includes": set(CALLBACK_INTERFACE_H_INCLUDES),
"methods": [method_context(operation) for operation in callback_interface.operations],
}
示例8: dictionary_context
def dictionary_context(dictionary):
includes.clear()
includes.update(DICTIONARY_CPP_INCLUDES)
return {
"cpp_class": v8_utilities.cpp_name(dictionary),
"header_includes": set(DICTIONARY_H_INCLUDES),
"members": [member_context(member) for member in sorted(dictionary.members, key=operator.attrgetter("name"))],
"v8_class": v8_utilities.v8_class_name(dictionary),
}
示例9: dictionary_context
def dictionary_context(dictionary):
includes.clear()
includes.update(DICTIONARY_CPP_INCLUDES)
return {
'cpp_class': v8_utilities.cpp_name(dictionary),
'header_includes': set(DICTIONARY_H_INCLUDES),
'members': [member_context(member)
for member in sorted(dictionary.members,
key=operator.attrgetter('name'))],
'v8_class': v8_utilities.v8_class_name(dictionary),
}
示例10: member_impl_context
def member_impl_context(member, interfaces_info, header_includes,
header_forward_decls):
idl_type = unwrap_nullable_if_needed(member.idl_type)
cpp_name = v8_utilities.cpp_name(member)
nullable_indicator_name = None
if not idl_type.cpp_type_has_null_value:
nullable_indicator_name = 'm_has' + cpp_name[0].upper() + cpp_name[1:]
def has_method_expression():
if nullable_indicator_name:
return nullable_indicator_name
elif idl_type.is_union_type:
return '!m_%s.isNull()' % cpp_name
elif idl_type.is_enum or idl_type.is_string_type:
return '!m_%s.IsNull()' % cpp_name
elif idl_type.name in ['Any', 'Object']:
return '!(m_{0}.IsEmpty() || m_{0}.IsNull() || m_{0}.IsUndefined())'.format(cpp_name)
elif idl_type.name == 'Dictionary':
return '!m_%s.IsUndefinedOrNull()' % cpp_name
else:
return 'm_%s' % cpp_name
cpp_default_value = None
if member.default_value and not member.default_value.is_null:
cpp_default_value = idl_type.literal_cpp_value(member.default_value)
forward_decl_name = idl_type.impl_forward_declaration_name
if forward_decl_name:
includes.update(idl_type.impl_includes_for_type(interfaces_info))
header_forward_decls.add(forward_decl_name)
else:
header_includes.update(idl_type.impl_includes_for_type(interfaces_info))
setter_value = 'value'
if idl_type.is_array_buffer_view_or_typed_array:
setter_value += '.View()'
return {
'cpp_default_value': cpp_default_value,
'cpp_name': cpp_name,
'getter_expression': 'm_' + cpp_name,
'getter_name': getter_name_for_dictionary_member(member),
'has_method_expression': has_method_expression(),
'has_method_name': has_method_name_for_dictionary_member(member),
'is_nullable': idl_type.is_nullable,
'is_traceable': idl_type.is_traceable,
'member_cpp_type': idl_type.cpp_type_args(used_in_cpp_sequence=True),
'null_setter_name': null_setter_name_for_dictionary_member(member),
'nullable_indicator_name': nullable_indicator_name,
'rvalue_cpp_type': idl_type.cpp_type_args(used_as_rvalue_type=True),
'setter_name': setter_name_for_dictionary_member(member),
'setter_value': setter_value,
}
示例11: private_script_interface_context
def private_script_interface_context(private_script_interface):
includes.clear()
includes.update(BLINK_IN_JS_INTERFACE_CPP_INCLUDES)
return {
'cpp_class': private_script_interface.name,
'forward_declarations': forward_declarations(private_script_interface),
'header_includes': set(BLINK_IN_JS_INTERFACE_H_INCLUDES),
'methods': [method_context(operation)
for operation in private_script_interface.operations],
'v8_class': v8_utilities.v8_class_name(private_script_interface),
}
示例12: generate_callback_interface
def generate_callback_interface(callback_interface):
includes.clear()
includes.update(CALLBACK_INTERFACE_CPP_INCLUDES)
return {
'conditional_string': v8_utilities.conditional_string(callback_interface),
'cpp_class': callback_interface.name,
'v8_class': v8_utilities.v8_class_name(callback_interface),
'header_includes': set(CALLBACK_INTERFACE_H_INCLUDES),
'methods': [generate_method(operation)
for operation in callback_interface.operations],
}
示例13: legacy_callback_interface_context
def legacy_callback_interface_context(callback_interface, _):
includes.clear()
includes.update(LEGACY_CALLBACK_INTERFACE_CPP_INCLUDES)
return {
# TODO(bashi): Fix crbug.com/630986, and add 'methods'.
'constants': [constant_context(constant, callback_interface)
for constant in callback_interface.constants],
'cpp_class': callback_interface.name,
'header_includes': set(CALLBACK_INTERFACE_H_INCLUDES),
'interface_name': callback_interface.name,
'v8_class': v8_utilities.v8_class_name(callback_interface),
}
示例14: generate_callback_interface
def generate_callback_interface(callback_interface):
includes.clear()
includes.update(CALLBACK_INTERFACE_CPP_INCLUDES)
methods = [generate_method(operation) for operation in callback_interface.operations]
template_contents = {
'cpp_class_name': callback_interface.name,
'v8_class_name': v8_class_name(callback_interface),
'header_includes': CALLBACK_INTERFACE_H_INCLUDES,
'methods': methods,
}
return template_contents
示例15: generate_interface_code
def generate_interface_code(self, definitions, interface_name, interface):
interface_info = self.info_provider.interfaces_info[interface_name]
full_path = interface_info.get('full_path')
component = idl_filename_to_component(full_path)
include_paths = interface_info.get('dependencies_include_paths')
# Select appropriate Jinja template and contents function
#
# A callback interface with constants needs a special handling.
# https://heycam.github.io/webidl/#legacy-callback-interface-object
if interface.is_callback and len(interface.constants) > 0:
header_template_filename = 'legacy_callback_interface.h.tmpl'
cpp_template_filename = 'legacy_callback_interface.cpp.tmpl'
interface_context = v8_callback_interface.legacy_callback_interface_context
elif interface.is_callback:
header_template_filename = 'callback_interface.h.tmpl'
cpp_template_filename = 'callback_interface.cpp.tmpl'
interface_context = v8_callback_interface.callback_interface_context
elif interface.is_partial:
interface_context = v8_interface.interface_context
header_template_filename = 'partial_interface.h.tmpl'
cpp_template_filename = 'partial_interface.cpp.tmpl'
interface_name += 'Partial'
assert component == 'core'
component = 'modules'
include_paths = interface_info.get('dependencies_other_component_include_paths')
else:
header_template_filename = 'interface.h.tmpl'
cpp_template_filename = 'interface.cpp.tmpl'
interface_context = v8_interface.interface_context
template_context = interface_context(interface, definitions.interfaces)
includes.update(interface_info.get('cpp_includes', {}).get(component, set()))
if not interface.is_partial and not is_testing_target(full_path):
template_context['header_includes'].add(self.info_provider.include_path_for_export)
template_context['exported'] = self.info_provider.specifier_for_export
# Add the include for interface itself
if IdlType(interface_name).is_typed_array:
template_context['header_includes'].add('core/typed_arrays/DOMTypedArray.h')
else:
template_context['header_includes'].add(interface_info['include_path'])
template_context['header_includes'].update(
interface_info.get('additional_header_includes', []))
header_template = self.jinja_env.get_template(header_template_filename)
cpp_template = self.jinja_env.get_template(cpp_template_filename)
header_text, cpp_text = self.render_template(
include_paths, header_template, cpp_template, template_context,
component)
header_path, cpp_path = self.output_paths(interface_name)
return (
(header_path, header_text),
(cpp_path, cpp_text),
)