in bindings/scripts/generate_event_interfaces.py [0:0]
def write_event_interfaces_file(event_idl_files, destination_filename, suffix):
def interface_line(full_path):
relative_dir_local = os.path.dirname(os.path.relpath(full_path, source_dir))
relative_dir_posix = relative_dir_local.replace(os.sep, posixpath.sep)
idl_file_contents = get_file_contents(full_path)
interface_name = get_first_interface_name_from_idl(idl_file_contents)
extended_attributes = get_interface_extended_attributes_from_idl(idl_file_contents)
extended_attributes_list = [
(name, extended_attributes[name])
for name in EXPORTED_EXTENDED_ATTRIBUTES
if name in extended_attributes]
return (posixpath.join(relative_dir_posix, interface_name),
extended_attributes_list)
lines = [
'{',
'metadata: {',
' namespace: "Event",'
]
if suffix:
lines.append(' suffix: "' + suffix + '",')
lines.append(' export: "%s_EXPORT",' % suffix.upper())
else:
lines.append(' export: "CORE_EXPORT",')
lines.extend([
'},',
'data: ['
])
interface_lines = [interface_line(event_idl_file)
for event_idl_file in event_idl_files]
interface_lines.sort()
for name, attributes in interface_lines:
lines.extend([
' {',
' name: "%s",' % name
])
for param, value in attributes:
if param == 'RuntimeEnabled':
value += 'Enabled'
lines.append(' %s: "%s",' % (param, value))
lines.append(' },')
lines.extend([
']',
'}'
])
write_file('\n'.join(lines), destination_filename)