本文整理汇总了Python中idl_types.IdlType.set_callback_functions方法的典型用法代码示例。如果您正苦于以下问题:Python IdlType.set_callback_functions方法的具体用法?Python IdlType.set_callback_functions怎么用?Python IdlType.set_callback_functions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idl_types.IdlType
的用法示例。
在下文中一共展示了IdlType.set_callback_functions方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_code
# 需要导入模块: from idl_types import IdlType [as 别名]
# 或者: from idl_types.IdlType import set_callback_functions [as 别名]
def generate_code(self, definitions, definition_name):
"""Returns .h/.cpp code as ((path, content)...)."""
# Set local type info
IdlType.set_callback_functions(definitions.callback_functions.keys())
IdlType.set_enums((enum.name, enum.values)
for enum in definitions.enumerations.values())
return self.generate_code_internal(definitions, definition_name)
示例2: generate_code
# 需要导入模块: from idl_types import IdlType [as 别名]
# 或者: from idl_types.IdlType import set_callback_functions [as 别名]
def generate_code(self, definitions, definition_name):
"""Returns .h/.cpp code as ((path, content)...)."""
# Set local type info
IdlType.set_callback_functions(definitions.callback_functions.keys())
IdlType.set_enums((enum.name, enum.values)
for enum in definitions.enumerations.values())
# Resolve typedefs
definitions.resolve_typedefs(self.info_provider.component_info['typedefs'])
return self.generate_code_internal(definitions, definition_name)
示例3: generate_code
# 需要导入模块: from idl_types import IdlType [as 别名]
# 或者: from idl_types.IdlType import set_callback_functions [as 别名]
def generate_code(self, definitions, definition_name):
"""Returns .h/.cpp code as ((path, content)...)."""
# Set local type info
if not should_generate_code(definitions):
return set()
IdlType.set_callback_functions(definitions.callback_functions.keys())
# Resolve typedefs
self.typedef_resolver.resolve(definitions, definition_name)
return self.generate_code_internal(definitions, definition_name)
示例4: set_global_type_info
# 需要导入模块: from idl_types import IdlType [as 别名]
# 或者: from idl_types.IdlType import set_callback_functions [as 别名]
def set_global_type_info(self):
interfaces_info = self.info_provider.interfaces_info
set_ancestors(interfaces_info['ancestors'])
IdlType.set_callback_interfaces(interfaces_info['callback_interfaces'])
IdlType.set_dictionaries(interfaces_info['dictionaries'])
IdlType.set_enums(self.info_provider.enumerations)
IdlType.set_callback_functions(self.info_provider.callback_functions)
IdlType.set_implemented_as_interfaces(interfaces_info['implemented_as_interfaces'])
IdlType.set_garbage_collected_types(interfaces_info['garbage_collected_interfaces'])
set_component_dirs(interfaces_info['component_dirs'])
示例5: generate_code
# 需要导入模块: from idl_types import IdlType [as 别名]
# 或者: from idl_types.IdlType import set_callback_functions [as 别名]
def generate_code(self, definitions, interface_name):
"""Returns .h/.cpp code as (header_text, cpp_text)."""
try:
interface = definitions.interfaces[interface_name]
except KeyError:
raise Exception('%s not in IDL definitions' % interface_name)
# Store other interfaces for introspection
interfaces.update(definitions.interfaces)
# Set local type info
IdlType.set_callback_functions(definitions.callback_functions.keys())
IdlType.set_enums((enum.name, enum.values)
for enum in definitions.enumerations.values())
# Select appropriate Jinja template and contents function
if interface.is_callback:
header_template_filename = 'callback_interface.h'
cpp_template_filename = 'callback_interface.cpp'
interface_context = v8_callback_interface.callback_interface_context
elif 'PrivateScriptInterface' in interface.extended_attributes:
# Currently private scripts don't have dependencies. Once private scripts have dependencies,
# we should add them to interface_info.
header_template_filename = 'private_script_interface.h'
cpp_template_filename = 'private_script_interface.cpp'
interface_context = v8_private_script_interface.private_script_interface_context
else:
header_template_filename = 'interface.h'
cpp_template_filename = 'interface.cpp'
interface_context = v8_interface.interface_context
header_template = self.jinja_env.get_template(header_template_filename)
cpp_template = self.jinja_env.get_template(cpp_template_filename)
# Compute context (input values for Jinja)
template_context = interface_context(interface)
template_context['code_generator'] = module_pyname
# Add includes for interface itself and any dependencies
interface_info = self.interfaces_info[interface_name]
if 'PrivateScriptInterface' not in interface.extended_attributes:
template_context['header_includes'].add(interface_info['include_path'])
template_context['header_includes'] = sorted(template_context['header_includes'])
includes.update(interface_info.get('dependencies_include_paths', []))
template_context['cpp_includes'] = sorted(includes)
# Render Jinja templates
header_text = header_template.render(template_context)
cpp_text = cpp_template.render(template_context)
return header_text, cpp_text
示例6: generate_code
# 需要导入模块: from idl_types import IdlType [as 别名]
# 或者: from idl_types.IdlType import set_callback_functions [as 别名]
def generate_code(self, definitions, definition_name):
"""Returns .h/.cpp code as (header_text, cpp_text)."""
# Set local type info
IdlType.set_callback_functions(definitions.callback_functions.keys())
IdlType.set_enums((enum.name, enum.values)
for enum in definitions.enumerations.values())
if definition_name in definitions.interfaces:
return self.generate_interface_code(
definitions, definition_name,
definitions.interfaces[definition_name])
if definition_name in definitions.dictionaries:
return self.generate_dictionary_code(
definitions, definition_name,
definitions.dictionaries[definition_name])
raise ValueError('%s is not in IDL definitions' % definition_name)
示例7: generate_code
# 需要导入模块: from idl_types import IdlType [as 别名]
# 或者: from idl_types.IdlType import set_callback_functions [as 别名]
def generate_code(self, definitions, interface_name):
"""Returns .h/.cpp code as (header_text, cpp_text)."""
try:
interface = definitions.interfaces[interface_name]
except KeyError:
raise Exception('%s not in IDL definitions' % interface_name)
# Store other interfaces for introspection
interfaces.update(definitions.interfaces)
# Set local type info
IdlType.set_callback_functions(definitions.callback_functions.keys())
IdlType.set_enums((enum.name, enum.values)
for enum in definitions.enumerations.values())
# Select appropriate Jinja template and contents function
if interface.is_callback:
header_template_filename = 'callback_interface.h'
cpp_template_filename = 'callback_interface.cpp'
generate_contents = v8_callback_interface.generate_callback_interface
else:
header_template_filename = 'interface.h'
cpp_template_filename = 'interface.cpp'
generate_contents = v8_interface.generate_interface
header_template = self.jinja_env.get_template(header_template_filename)
cpp_template = self.jinja_env.get_template(cpp_template_filename)
# Generate contents (input parameters for Jinja)
template_contents = generate_contents(interface)
template_contents['code_generator'] = module_pyname
# Add includes for interface itself and any dependencies
interface_info = self.interfaces_info[interface_name]
template_contents['header_includes'].add(interface_info['include_path'])
template_contents['header_includes'] = sorted(template_contents['header_includes'])
includes.update(interface_info.get('dependencies_include_paths', []))
template_contents['cpp_includes'] = sorted(includes)
# Render Jinja templates
header_text = header_template.render(template_contents)
cpp_text = cpp_template.render(template_contents)
return header_text, cpp_text
示例8: generate_code
# 需要导入模块: from idl_types import IdlType [as 别名]
# 或者: from idl_types.IdlType import set_callback_functions [as 别名]
def generate_code(self, definitions, interface_name,
idl_filename, idl_pickle_filename, only_if_changed):
"""Returns .h/.cpp/.dart code as (header_text, cpp_text, dart_text)."""
try:
interface = definitions.interfaces[interface_name]
except KeyError:
raise Exception('%s not in IDL definitions' % interface_name)
# Store other interfaces for introspection
interfaces.update(definitions.interfaces)
# Set local type info
IdlType.set_callback_functions(definitions.callback_functions.keys())
IdlType.set_enums((enum.name, enum.values)
for enum in definitions.enumerations.values())
# Select appropriate Jinja template and contents function
if interface.is_callback:
header_template_filename = 'callback_interface_h.template'
cpp_template_filename = 'callback_interface_cpp.template'
dart_template_filename = 'callback_interface_dart.template'
generate_contents = dart_callback_interface.generate_callback_interface
else:
header_template_filename = 'interface_h.template'
cpp_template_filename = 'interface_cpp.template'
dart_template_filename = 'interface_dart.template'
generate_contents = dart_interface.interface_context
header_template = self.jinja_env.get_template(header_template_filename)
cpp_template = self.jinja_env.get_template(cpp_template_filename)
dart_template = self.jinja_env.get_template(dart_template_filename)
# Generate contents (input parameters for Jinja)
template_contents = generate_contents(interface)
template_contents['code_generator'] = module_pyname
# Add includes for interface itself and any dependencies
interface_info = self.interfaces_info[interface_name]
template_contents['header_includes'].add(interface_info['include_path'])
template_contents['header_includes'] = sorted(template_contents['header_includes'])
includes.update(interface_info.get('dependencies_include_paths', []))
template_contents['cpp_includes'] = sorted(includes)
# If PrivateDart is set, read the custom dart file and add it to our
# template parameters.
if 'PrivateDart' in interface.extended_attributes:
template_contents['private_dart'] = True
idl_world = {'interface': None, 'callback': None}
# Load the pickle file for this IDL.
if os.path.isfile(idl_pickle_filename):
with open(idl_pickle_filename) as idl_pickle_file:
idl_global_data = pickle.load(idl_pickle_file)
idl_pickle_file.close()
idl_world['interface'] = idl_global_data['interface']
idl_world['callback'] = idl_global_data['callback']
if 'interface_name' in template_contents:
interface_global = {'component_dir': interface_info['component_dir'],
'name': template_contents['interface_name'],
'parent_interface': template_contents['parent_interface'],
'is_active_dom_object': template_contents['is_active_dom_object'],
'has_resolver': template_contents['interface_name'],
'native_entries': sorted(template_contents['native_entries'], key=lambda(x): x['blink_entry']),
}
idl_world['interface'] = interface_global
else:
callback_global = {'name': template_contents['cpp_class']}
idl_world['callback'] = callback_global
write_pickle_file(idl_pickle_filename, idl_world, only_if_changed)
# Render Jinja templates
header_text = header_template.render(template_contents)
cpp_text = cpp_template.render(template_contents)
dart_text = dart_template.render(template_contents)
return header_text, cpp_text, dart_text
示例9: generate_code
# 需要导入模块: from idl_types import IdlType [as 别名]
# 或者: from idl_types.IdlType import set_callback_functions [as 别名]
def generate_code(self, definitions, interface_name, idl_pickle_filename,
only_if_changed):
"""Returns .h/.cpp code as (header_text, cpp_text)."""
try:
interface = definitions.interfaces[interface_name]
except KeyError:
raise Exception('%s not in IDL definitions' % interface_name)
# Store other interfaces for introspection
interfaces.update(definitions.interfaces)
# Set local type info
IdlType.set_callback_functions(definitions.callback_functions.keys())
IdlType.set_enums((enum.name, enum.values)
for enum in definitions.enumerations.values())
# Select appropriate Jinja template and contents function
if interface.is_callback:
header_template_filename = 'callback_interface_h.template'
cpp_template_filename = 'callback_interface_cpp.template'
generate_contents = dart_callback_interface.generate_callback_interface
else:
header_template_filename = 'interface_h.template'
cpp_template_filename = 'interface_cpp.template'
generate_contents = dart_interface.generate_interface
header_template = self.jinja_env.get_template(header_template_filename)
cpp_template = self.jinja_env.get_template(cpp_template_filename)
# Generate contents (input parameters for Jinja)
template_contents = generate_contents(interface)
template_contents['code_generator'] = module_pyname
# Add includes for interface itself and any dependencies
interface_info = self.interfaces_info[interface_name]
template_contents['header_includes'].add(interface_info['include_path'])
template_contents['header_includes'] = sorted(template_contents['header_includes'])
includes.update(interface_info.get('dependencies_include_paths', []))
# Remove includes that are not needed for Dart and trigger fatal
# compile warnings if included. These IDL files need to be
# imported by Dart to generate the list of events but the
# associated header files do not contain any code used by Dart.
includes.discard('core/dom/GlobalEventHandlers.h')
includes.discard('core/frame/DOMWindowEventHandlers.h')
template_contents['cpp_includes'] = sorted(includes)
idl_world = {'interface': None, 'callback': None}
# Load the pickle file for this IDL.
if os.path.isfile(idl_pickle_filename):
with open(idl_pickle_filename) as idl_pickle_file:
idl_global_data = pickle.load(idl_pickle_file)
idl_pickle_file.close()
idl_world['interface'] = idl_global_data['interface']
idl_world['callback'] = idl_global_data['callback']
if 'interface_name' in template_contents:
interface_global = {'name': template_contents['interface_name'],
'parent_interface': template_contents['parent_interface'],
'is_active_dom_object': template_contents['is_active_dom_object'],
'is_event_target': template_contents['is_event_target'],
'has_resolver': template_contents['interface_name'] not in INTERFACES_WITHOUT_RESOLVERS,
'is_node': template_contents['is_node'],
'conditional_string': template_contents['conditional_string'],
}
idl_world['interface'] = interface_global
else:
callback_global = {'name': template_contents['cpp_class']}
idl_world['callback'] = callback_global
write_pickle_file(idl_pickle_filename, idl_world, only_if_changed)
# Render Jinja templates
header_text = header_template.render(template_contents)
cpp_text = cpp_template.render(template_contents)
return header_text, cpp_text