diff options
Diffstat (limited to 'src/components/dbus/codegen')
-rw-r--r-- | src/components/dbus/codegen/code_formatter.py | 58 | ||||
-rw-r--r-- | src/components/dbus/codegen/ford_xml_parser.py | 231 | ||||
-rw-r--r-- | src/components/dbus/codegen/introspection_xml.cc | 327 | ||||
-rwxr-xr-x | src/components/dbus/codegen/make_hmi_requests.py | 343 | ||||
-rwxr-xr-x | src/components/dbus/codegen/make_introspection_c.py | 126 | ||||
-rwxr-xr-x | src/components/dbus/codegen/make_message_descriptions.py | 273 | ||||
-rwxr-xr-x | src/components/dbus/codegen/make_notifications_qml.py | 387 | ||||
-rwxr-xr-x | src/components/dbus/codegen/make_qml_dbus_cpp.py | 736 | ||||
-rwxr-xr-x | src/components/dbus/codegen/make_qml_dbus_qml.py | 217 | ||||
-rw-r--r-- | src/components/dbus/codegen/make_qml_requests_cpp.py | 253 | ||||
-rwxr-xr-x | src/components/dbus/codegen/make_request_to_sdl.py | 335 |
11 files changed, 0 insertions, 3286 deletions
diff --git a/src/components/dbus/codegen/code_formatter.py b/src/components/dbus/codegen/code_formatter.py deleted file mode 100644 index c3eb1b7815..0000000000 --- a/src/components/dbus/codegen/code_formatter.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# @file code_formatter.py -# @brief Utility that helps to manage indents in generated code -# -# This file is a part of HMI D-Bus layer. -# -# Copyright (c) 2013, Ford Motor Company -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with the -# distribution. -# -# Neither the name of the Ford Motor Company nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -class CodeBlock: - indent = 0 - def __init__(self, out): - self.out = out - if type(out) == file: - self.indent = 0 - elif type(out) == CodeBlock: - self.indent = out.indent - def __enter__(self): - self.indent += 1 - return self - def __exit__(self, exc_type, exc_value, traceback): - if self.indent >= 1: - self.indent -= 1 - def write(self, s): - for string in s.splitlines(True): - self.out.write(' ' * self.indent + string) - -# vim: set ts=4 sw=4 et: - diff --git a/src/components/dbus/codegen/ford_xml_parser.py b/src/components/dbus/codegen/ford_xml_parser.py deleted file mode 100644 index 4f9f222d24..0000000000 --- a/src/components/dbus/codegen/ford_xml_parser.py +++ /dev/null @@ -1,231 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# @file ford_xml_parser.py -# @brief Parser for HMI_API.xml -# -# This file is a part of HMI D-Bus layer. -# -# Copyright (c) 2013, Ford Motor Company -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with the -# distribution. -# -# Neither the name of the Ford Motor Company nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -from xml.etree import ElementTree -from collections import OrderedDict - -node_name = '/com/ford/hmi' - -class ParamDesc: - pass - -class FordXmlParser: - def __init__(self, in_el_tree, interface_path=None): - self.interface_path = interface_path - self.el_tree = in_el_tree - self.find_enums() - self.find_structs() - - def find_enums(self): - self.enums = dict() - for interface_el in self.el_tree.findall('interface'): - interface_name = interface_el.get('name') - for enum_el in interface_el.findall('enum'): - enum_name = enum_el.get('name') - self.enums[(interface_name,enum_name)] = enum_el - - - def make_param_desc(self, param_el, iface=None): - param_desc = ParamDesc() - param_desc.name = param_el.get('name') - param_desc.type = param_el.get('type') - param_desc.enum = False - param_desc.struct = False - param_desc.fulltype = param_desc.type - if param_el.get('mandatory') == 'false': - param_desc.mandatory = False - else: - param_desc.mandatory = True - if param_el.get('array') == 'true': - param_desc.array = True - else: - param_desc.array = False - param_desc.minValue = param_el.get('minvalue') if param_el.get('minvalue') else 0 - param_desc.maxValue = param_el.get('maxvalue') - param_desc.minLength = param_el.get('minlength') if param_el.get('minlength') else 0 - param_desc.maxLength = param_el.get('maxlength') - param_desc.minSize = param_el.get('minsize') - param_desc.maxSize = param_el.get('maxsize') - - param_desc.restricted = param_desc.minValue != None or \ - param_desc.maxValue != None or \ - param_desc.minLength > 0 or \ - param_desc.maxLength > 0 - param_desc.restrictedArray = param_desc.array and (param_desc.minSize > 0 or param_desc.maxSize > 0) - if iface is None: - return param_desc - if param_desc.type not in ['Integer', 'String', 'Boolean', 'Float']: - param_type = param_desc.type.split('.') - if len(param_type) > 1: - param_type = (param_type[0], param_type[1]) - else: - param_type = (iface, param_type[0]) - param_desc.fulltype = param_type - if param_type in self.enums: param_desc.enum = True - elif param_type in self.structs: param_desc.struct = True - return param_desc - - - def find_structs(self): - self.structs = OrderedDict() - for interface_el in self.el_tree.findall('interface'): - interface_name = interface_el.get('name') - for struct_el in interface_el.findall('struct'): - struct_name = struct_el.get('name') - self.structs[(interface_name, struct_name)] = [] - - for interface_el in self.el_tree.findall('interface'): - interface_name = interface_el.get('name') - for struct_el in interface_el.findall('struct'): - struct_name = struct_el.get('name') - for param_el in struct_el.findall('param'): - param_desc = self.make_param_desc(param_el, interface_name) - self.structs[(interface_name, struct_name)].append(param_desc) - - - def convert_struct_to_dbus(self, param_type): - ret = '(' - struct = self.structs[param_type] - for param in struct: - ret = ret + self.convert_to_dbus_type(param) - ret = ret + ')' - return ret - - - def convert_to_dbus_type(self, param): - if param.type == 'Integer': restype = 'i' - elif param.type == 'String': restype = 's' - elif param.type == 'Boolean': restype = 'b' - elif param.type == 'Float': restype = 'd' # D-Bus double - elif param.enum: restype = 'i' # D-Bus 32-bit signed int - elif param.struct: restype = self.convert_struct_to_dbus(param.fulltype) - else: raise RuntimeError('Unknown type: ' + param.type) - if param.array: restype = 'a' + restype - if not param.mandatory: restype = '(b' + restype + ')' - return restype - - - def find_notifications(self, interface_el): - notifications = list() - for function_el in interface_el.findall('function[@messagetype="notification"]'): - notifications.append(function_el) - return notifications - - - def find_notifications_by_provider(self, interface_el, provider): - notifications = list() - condition = 'function[@messagetype="notification"][@provider="%s"]' % provider - for function_el in interface_el.findall(condition): - notifications.append(function_el) - return notifications - - - def find_request_response_pairs(self, interface_el): - result = list() - request_els = interface_el.findall('function[@messagetype="request"]') - response_els = interface_el.findall('function[@messagetype="response"]') - for request_el in request_els: - name = request_el.get('name') - response_el = next(r for r in response_els if r.get('name') == name) - result.append((request_el, response_el)) - return result - - - def find_request_response_pairs_by_provider(self, interface_el, provider): - result = list() - condition = 'function[@messagetype="request"][@provider="%s"]' % provider - request_els = interface_el.findall(condition) - response_els = interface_el.findall('function[@messagetype="response"]') - for request_el in request_els: - name = request_el.get('name') - response_el = next(r for r in response_els if r.get('name') == name) - result.append((request_el, response_el)) - return result - - - def convert_to_signal(self, notification_el, interface): - result = ElementTree.Element('signal') - result.set('name', notification_el.get('name')) - for param_el in notification_el.findall('param'): - self.create_arg_element(result, param_el, interface) - return result - - - def convert_to_method(self, (request_el, response_el), interface): - result = ElementTree.Element('method') - result.set('name', request_el.get('name')) - for param_el in request_el.findall('param'): - arg_el = self.create_arg_element(result, param_el, interface) - arg_el.set('direction', 'in') - - arg_el = ElementTree.SubElement(result, 'arg') - arg_el.set('name', 'retCode') - arg_el.set('type', 'i') - arg_el.set('direction', 'out') - - for param_el in response_el.findall('param'): - arg_el = self.create_arg_element(result, param_el, interface) - arg_el.set('direction', 'out') - return result - - - def create_arg_element(self, parent, param_el, interface): - arg_el = ElementTree.SubElement(parent, 'arg') - arg_el.set('name', param_el.get('name')) - arg_el.set('type', self.convert_to_dbus_type(self.make_param_desc(param_el, interface))) - return arg_el - - - def create_introspection_iface_el(self, interface_el, provider): - interface = interface_el.get('name') - interface_name = self.interface_path + '.' + interface - - notifications = self.find_notifications_by_provider(interface_el, provider) - signals = [self.convert_to_signal(n, interface) for n in notifications] - - request_responses = self.find_request_response_pairs_by_provider(interface_el, provider) - methods = [self.convert_to_method(r, interface) for r in request_responses] - - if signals or methods: - el = ElementTree.Element('interface', attrib={'name':interface_name}) - for m in methods: el.append(m) - for s in signals: el.append(s) - return el - - - diff --git a/src/components/dbus/codegen/introspection_xml.cc b/src/components/dbus/codegen/introspection_xml.cc deleted file mode 100644 index 210c232a4d..0000000000 --- a/src/components/dbus/codegen/introspection_xml.cc +++ /dev/null @@ -1,327 +0,0 @@ -// Warning! This file is generated by 'make_introspection_c.py'. Edit at your -// own risk. -/** - * @file instrospections_xml.cc - * @brief D-Bus introspection XML as C-string - * - * This file is a part of HMI D-Bus layer. - */ -// Copyright (c) 2013, Ford Motor Company -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following -// disclaimer in the documentation and/or other materials provided with the -// distribution. -// -// Neither the name of the Ford Motor Company nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -char introspection_xml[] = { - 0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20, 0x6e, 0x6f, - 0x64, 0x65, 0x20, 0x50, 0x55, 0x42, 0x4c, 0x49, 0x43, 0x20, 0x22, 0x2d, - 0x2f, 0x2f, 0x66, 0x72, 0x65, 0x65, 0x64, 0x65, 0x73, 0x6b, 0x74, 0x6f, - 0x70, 0x2f, 0x2f, 0x44, 0x54, 0x44, 0x20, 0x44, 0x2d, 0x42, 0x55, 0x53, - 0x20, 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x20, 0x49, 0x6e, 0x74, 0x72, - 0x6f, 0x73, 0x70, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x31, 0x2e, - 0x30, 0x2f, 0x2f, 0x45, 0x4e, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, - 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, - 0x65, 0x73, 0x6b, 0x74, 0x6f, 0x70, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x73, - 0x74, 0x61, 0x6e, 0x64, 0x61, 0x72, 0x64, 0x73, 0x2f, 0x64, 0x62, 0x75, - 0x73, 0x2f, 0x31, 0x2e, 0x30, 0x2f, 0x69, 0x6e, 0x74, 0x72, 0x6f, 0x73, - 0x70, 0x65, 0x63, 0x74, 0x2e, 0x64, 0x74, 0x64, 0x22, 0x3e, 0x0a, 0x3c, - 0x6e, 0x6f, 0x64, 0x65, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x2f, - 0x63, 0x6f, 0x6d, 0x2f, 0x66, 0x6f, 0x72, 0x64, 0x2f, 0x68, 0x6d, 0x69, - 0x22, 0x3e, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, - 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x63, 0x6f, 0x6d, 0x2e, 0x66, - 0x6f, 0x72, 0x64, 0x2e, 0x68, 0x6d, 0x69, 0x2e, 0x73, 0x64, 0x6c, 0x2e, - 0x42, 0x61, 0x73, 0x69, 0x63, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3e, 0x3c, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x6c, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x4f, 0x6e, - 0x52, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x41, 0x75, 0x64, 0x69, 0x6f, 0x53, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, - 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x61, 0x70, 0x70, 0x49, 0x44, 0x22, - 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x69, 0x22, 0x20, 0x2f, 0x3e, - 0x3c, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x3e, 0x3c, 0x73, 0x69, - 0x67, 0x6e, 0x61, 0x6c, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x4f, - 0x6e, 0x53, 0x44, 0x4c, 0x50, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, - 0x6e, 0x63, 0x65, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x22, - 0x20, 0x2f, 0x3e, 0x3c, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x20, 0x6e, - 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x4f, 0x6e, 0x46, 0x69, 0x6c, 0x65, 0x52, - 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x22, 0x3e, 0x3c, 0x61, 0x72, 0x67, - 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x4e, - 0x61, 0x6d, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x73, - 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, - 0x65, 0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x22, - 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x69, 0x22, 0x20, 0x2f, 0x3e, - 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x61, - 0x70, 0x70, 0x49, 0x44, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, - 0x69, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x61, - 0x6c, 0x3e, 0x3c, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x20, 0x6e, 0x61, - 0x6d, 0x65, 0x3d, 0x22, 0x4f, 0x6e, 0x41, 0x70, 0x70, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x65, 0x72, 0x65, 0x64, 0x22, 0x3e, 0x3c, 0x61, 0x72, - 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x61, 0x70, 0x70, 0x6c, - 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x20, 0x74, 0x79, 0x70, - 0x65, 0x3d, 0x22, 0x28, 0x73, 0x28, 0x62, 0x73, 0x29, 0x28, 0x62, 0x73, - 0x29, 0x28, 0x73, 0x73, 0x28, 0x62, 0x69, 0x29, 0x28, 0x62, 0x62, 0x29, - 0x29, 0x73, 0x28, 0x62, 0x61, 0x28, 0x73, 0x69, 0x29, 0x29, 0x28, 0x62, - 0x61, 0x73, 0x29, 0x69, 0x69, 0x62, 0x28, 0x62, 0x61, 0x69, 0x29, 0x28, - 0x62, 0x62, 0x29, 0x28, 0x62, 0x61, 0x69, 0x29, 0x29, 0x22, 0x20, 0x2f, - 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, - 0x74, 0x74, 0x73, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, - 0x65, 0x3d, 0x22, 0x28, 0x62, 0x61, 0x28, 0x73, 0x69, 0x29, 0x29, 0x22, - 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, - 0x3d, 0x22, 0x76, 0x72, 0x53, 0x79, 0x6e, 0x6f, 0x6e, 0x79, 0x6d, 0x73, - 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, 0x62, 0x61, 0x73, - 0x29, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, - 0x6d, 0x65, 0x3d, 0x22, 0x72, 0x65, 0x73, 0x75, 0x6d, 0x65, 0x56, 0x72, - 0x47, 0x72, 0x61, 0x6d, 0x6d, 0x61, 0x72, 0x73, 0x22, 0x20, 0x74, 0x79, - 0x70, 0x65, 0x3d, 0x22, 0x28, 0x62, 0x62, 0x29, 0x22, 0x20, 0x2f, 0x3e, - 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x70, - 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, 0x20, 0x74, 0x79, 0x70, - 0x65, 0x3d, 0x22, 0x28, 0x62, 0x69, 0x29, 0x22, 0x20, 0x2f, 0x3e, 0x3c, - 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x3e, 0x3c, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x6c, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x4f, 0x6e, - 0x41, 0x70, 0x70, 0x55, 0x6e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, - 0x72, 0x65, 0x64, 0x22, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, - 0x6d, 0x65, 0x3d, 0x22, 0x75, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, - 0x65, 0x64, 0x44, 0x69, 0x73, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, - 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x62, 0x22, 0x20, 0x2f, - 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, - 0x61, 0x70, 0x70, 0x49, 0x44, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, - 0x22, 0x69, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x2f, 0x73, 0x69, 0x67, 0x6e, - 0x61, 0x6c, 0x3e, 0x3c, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x20, 0x6e, - 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x50, 0x6c, 0x61, 0x79, 0x54, 0x6f, 0x6e, - 0x65, 0x22, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, - 0x3d, 0x22, 0x61, 0x70, 0x70, 0x49, 0x44, 0x22, 0x20, 0x74, 0x79, 0x70, - 0x65, 0x3d, 0x22, 0x69, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, - 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x6d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, - 0x22, 0x69, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x2f, 0x73, 0x69, 0x67, 0x6e, - 0x61, 0x6c, 0x3e, 0x3c, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x20, 0x6e, - 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x4f, 0x6e, 0x53, 0x44, 0x4c, 0x43, 0x6c, - 0x6f, 0x73, 0x65, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x73, 0x69, 0x67, 0x6e, - 0x61, 0x6c, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x4f, 0x6e, 0x50, - 0x75, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x22, 0x3e, 0x3c, 0x61, 0x72, 0x67, - 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x6f, 0x66, 0x66, 0x73, 0x65, - 0x74, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, 0x62, 0x69, - 0x29, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, - 0x6d, 0x65, 0x3d, 0x22, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x22, 0x20, - 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, 0x62, 0x69, 0x29, 0x22, 0x20, - 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, - 0x22, 0x66, 0x69, 0x6c, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x20, 0x74, - 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, 0x62, 0x69, 0x29, 0x22, 0x20, 0x2f, - 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, - 0x46, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x20, 0x74, 0x79, - 0x70, 0x65, 0x3d, 0x22, 0x73, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, - 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x73, 0x79, 0x6e, 0x63, - 0x46, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x20, 0x74, 0x79, - 0x70, 0x65, 0x3d, 0x22, 0x73, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, - 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x66, 0x69, 0x6c, 0x65, - 0x54, 0x79, 0x70, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, - 0x69, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, - 0x6d, 0x65, 0x3d, 0x22, 0x70, 0x65, 0x72, 0x73, 0x69, 0x73, 0x74, 0x65, - 0x6e, 0x74, 0x46, 0x69, 0x6c, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, - 0x3d, 0x22, 0x28, 0x62, 0x62, 0x29, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x2f, - 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x3e, 0x3c, 0x2f, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x3e, 0x3c, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x66, 0x61, 0x63, 0x65, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, - 0x63, 0x6f, 0x6d, 0x2e, 0x66, 0x6f, 0x72, 0x64, 0x2e, 0x68, 0x6d, 0x69, - 0x2e, 0x73, 0x64, 0x6c, 0x2e, 0x55, 0x49, 0x22, 0x3e, 0x3c, 0x73, 0x69, - 0x67, 0x6e, 0x61, 0x6c, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x4f, - 0x6e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, - 0x22, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, - 0x22, 0x61, 0x70, 0x70, 0x49, 0x44, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, - 0x3d, 0x22, 0x69, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x2f, 0x73, 0x69, 0x67, - 0x6e, 0x61, 0x6c, 0x3e, 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, - 0x61, 0x63, 0x65, 0x3e, 0x3c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, - 0x63, 0x65, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x63, 0x6f, 0x6d, - 0x2e, 0x66, 0x6f, 0x72, 0x64, 0x2e, 0x68, 0x6d, 0x69, 0x2e, 0x73, 0x64, - 0x6c, 0x2e, 0x53, 0x44, 0x4c, 0x22, 0x3e, 0x3c, 0x6d, 0x65, 0x74, 0x68, - 0x6f, 0x64, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x41, 0x63, 0x74, - 0x69, 0x76, 0x61, 0x74, 0x65, 0x41, 0x70, 0x70, 0x22, 0x3e, 0x3c, 0x61, - 0x72, 0x67, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x3d, 0x22, 0x69, 0x6e, 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, - 0x61, 0x70, 0x70, 0x49, 0x44, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, - 0x22, 0x69, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, - 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, 0x75, - 0x74, 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x72, 0x65, 0x74, - 0x43, 0x6f, 0x64, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, - 0x69, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, 0x69, - 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, 0x75, 0x74, - 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x69, 0x73, 0x53, 0x44, - 0x4c, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x22, 0x20, 0x74, 0x79, - 0x70, 0x65, 0x3d, 0x22, 0x62, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, - 0x67, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, - 0x22, 0x6f, 0x75, 0x74, 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, - 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, - 0x3d, 0x22, 0x28, 0x62, 0x28, 0x73, 0x73, 0x28, 0x62, 0x69, 0x29, 0x28, - 0x62, 0x62, 0x29, 0x29, 0x29, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, - 0x67, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, - 0x22, 0x6f, 0x75, 0x74, 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, - 0x69, 0x73, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x73, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x4e, 0x65, 0x65, 0x64, - 0x65, 0x64, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x62, 0x22, - 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, 0x69, 0x72, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, 0x75, 0x74, 0x22, 0x20, - 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x69, 0x73, 0x41, 0x70, 0x70, 0x50, - 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, - 0x76, 0x6f, 0x6b, 0x65, 0x64, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, - 0x22, 0x62, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, - 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, 0x75, - 0x74, 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x61, 0x70, 0x70, - 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x64, 0x50, 0x65, 0x72, 0x6d, 0x69, - 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, - 0x3d, 0x22, 0x28, 0x62, 0x61, 0x28, 0x73, 0x69, 0x28, 0x62, 0x62, 0x29, - 0x29, 0x29, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, - 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, 0x75, - 0x74, 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x69, 0x73, 0x41, - 0x70, 0x70, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x64, 0x22, 0x20, 0x74, - 0x79, 0x70, 0x65, 0x3d, 0x22, 0x62, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, - 0x72, 0x67, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x3d, 0x22, 0x6f, 0x75, 0x74, 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, - 0x22, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, 0x20, 0x74, - 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, 0x62, 0x69, 0x29, 0x22, 0x20, 0x2f, - 0x3e, 0x3c, 0x2f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x3e, 0x3c, 0x6d, - 0x65, 0x74, 0x68, 0x6f, 0x64, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, - 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x46, 0x72, 0x69, 0x65, 0x6e, - 0x64, 0x6c, 0x79, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x3e, - 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x3d, 0x22, 0x69, 0x6e, 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, - 0x3d, 0x22, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x6f, 0x64, - 0x65, 0x73, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x61, 0x73, - 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, 0x69, 0x72, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x69, 0x6e, 0x22, 0x20, - 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x6c, 0x61, 0x6e, 0x67, 0x75, 0x61, - 0x67, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, 0x62, - 0x69, 0x29, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, - 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, 0x75, - 0x74, 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x72, 0x65, 0x74, - 0x43, 0x6f, 0x64, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, - 0x69, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, 0x69, - 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, 0x75, 0x74, - 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x73, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, - 0x28, 0x62, 0x61, 0x28, 0x73, 0x28, 0x62, 0x73, 0x29, 0x28, 0x62, 0x73, - 0x29, 0x28, 0x62, 0x73, 0x29, 0x28, 0x62, 0x73, 0x29, 0x28, 0x62, 0x73, - 0x29, 0x29, 0x29, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x2f, 0x6d, 0x65, 0x74, - 0x68, 0x6f, 0x64, 0x3e, 0x3c, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x20, - 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, - 0x74, 0x4f, 0x66, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x73, 0x22, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, 0x69, 0x72, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x69, 0x6e, 0x22, 0x20, - 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x61, 0x70, 0x70, 0x49, 0x44, 0x22, - 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, 0x62, 0x69, 0x29, 0x22, - 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, 0x69, 0x72, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, 0x75, 0x74, 0x22, 0x20, - 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x72, 0x65, 0x74, 0x43, 0x6f, 0x64, - 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x69, 0x22, 0x20, - 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, 0x75, 0x74, 0x22, 0x20, 0x6e, - 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, - 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x20, 0x74, - 0x79, 0x70, 0x65, 0x3d, 0x22, 0x61, 0x28, 0x73, 0x69, 0x28, 0x62, 0x62, - 0x29, 0x29, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x2f, 0x6d, 0x65, 0x74, 0x68, - 0x6f, 0x64, 0x3e, 0x3c, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x20, 0x6e, - 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, - 0x44, 0x4c, 0x22, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, 0x69, 0x72, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, 0x75, 0x74, 0x22, - 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x72, 0x65, 0x74, 0x43, 0x6f, - 0x64, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x69, 0x22, - 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, 0x69, 0x72, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, 0x75, 0x74, 0x22, 0x20, - 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x69, 0x22, 0x20, 0x2f, - 0x3e, 0x3c, 0x2f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x3e, 0x3c, 0x6d, - 0x65, 0x74, 0x68, 0x6f, 0x64, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, - 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x22, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, 0x69, - 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, 0x75, 0x74, - 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x72, 0x65, 0x74, 0x43, - 0x6f, 0x64, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x69, - 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x64, 0x69, 0x72, - 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, 0x75, 0x74, 0x22, - 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x69, 0x22, 0x20, - 0x2f, 0x3e, 0x3c, 0x2f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x3e, 0x3c, - 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, - 0x22, 0x47, 0x65, 0x74, 0x55, 0x52, 0x4c, 0x53, 0x22, 0x3e, 0x3c, 0x61, - 0x72, 0x67, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x3d, 0x22, 0x69, 0x6e, 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, - 0x65, 0x3d, 0x22, 0x69, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, - 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, - 0x6f, 0x75, 0x74, 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x72, - 0x65, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, - 0x3d, 0x22, 0x69, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, - 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x6f, - 0x75, 0x74, 0x22, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x75, 0x72, - 0x6c, 0x73, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, 0x62, - 0x61, 0x28, 0x73, 0x28, 0x62, 0x73, 0x29, 0x29, 0x29, 0x22, 0x20, 0x2f, - 0x3e, 0x3c, 0x2f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x3e, 0x3c, 0x73, - 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, - 0x4f, 0x6e, 0x41, 0x70, 0x70, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, - 0x69, 0x6f, 0x6e, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x64, 0x22, 0x3e, - 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x61, - 0x70, 0x70, 0x49, 0x44, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, - 0x69, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, - 0x6d, 0x65, 0x3d, 0x22, 0x69, 0x73, 0x41, 0x70, 0x70, 0x50, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x76, 0x6f, - 0x6b, 0x65, 0x64, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, - 0x62, 0x62, 0x29, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, - 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x61, 0x70, 0x70, 0x52, 0x65, 0x76, - 0x6f, 0x6b, 0x65, 0x64, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x73, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, - 0x62, 0x61, 0x28, 0x73, 0x69, 0x28, 0x62, 0x62, 0x29, 0x29, 0x29, 0x22, - 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, - 0x3d, 0x22, 0x61, 0x70, 0x70, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x64, - 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, 0x62, 0x62, 0x29, - 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, - 0x65, 0x3d, 0x22, 0x61, 0x70, 0x70, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x43, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x74, - 0x4e, 0x65, 0x65, 0x64, 0x65, 0x64, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, - 0x3d, 0x22, 0x28, 0x62, 0x62, 0x29, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, - 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x61, 0x70, 0x70, - 0x55, 0x6e, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x65, 0x64, - 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, 0x62, 0x62, 0x29, - 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, - 0x65, 0x3d, 0x22, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, - 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, 0x62, 0x69, 0x29, 0x22, - 0x20, 0x2f, 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, - 0x3d, 0x22, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x79, 0x70, - 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x28, 0x62, 0x61, - 0x69, 0x29, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x2f, 0x73, 0x69, 0x67, 0x6e, - 0x61, 0x6c, 0x3e, 0x3c, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x20, 0x6e, - 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x4f, 0x6e, 0x53, 0x44, 0x4c, 0x43, 0x6f, - 0x6e, 0x73, 0x65, 0x6e, 0x74, 0x4e, 0x65, 0x65, 0x64, 0x65, 0x64, 0x22, - 0x3e, 0x3c, 0x61, 0x72, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, - 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, - 0x3d, 0x22, 0x28, 0x73, 0x73, 0x28, 0x62, 0x69, 0x29, 0x28, 0x62, 0x62, - 0x29, 0x29, 0x22, 0x20, 0x2f, 0x3e, 0x3c, 0x2f, 0x73, 0x69, 0x67, 0x6e, - 0x61, 0x6c, 0x3e, 0x3c, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x20, 0x6e, - 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x4f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x22, 0x3e, 0x3c, 0x61, 0x72, - 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x22, 0x20, 0x74, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x69, 0x22, - 0x20, 0x2f, 0x3e, 0x3c, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x3e, - 0x3c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x3e, - 0x3c, 0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x3e, 0x00};
\ No newline at end of file diff --git a/src/components/dbus/codegen/make_hmi_requests.py b/src/components/dbus/codegen/make_hmi_requests.py deleted file mode 100755 index 4716d40439..0000000000 --- a/src/components/dbus/codegen/make_hmi_requests.py +++ /dev/null @@ -1,343 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# @file make_qml_dbus_cpp.py -# @brief Generator of QML to QDbus C++ part -# -# This file is a part of HMI D-Bus layer. -# -# Copyright (c) 2014, Ford Motor Company -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with the -# distribution. -# -# Neither the name of the Ford Motor Company nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -from argparse import ArgumentParser -import os.path -from sys import argv -from xml.etree import ElementTree -from copy import copy -from ford_xml_parser import FordXmlParser, ParamDesc -from code_formatter import CodeBlock - -prefix_class_item = 'Declarative' -invoke_type_connection = 'Direct' - -def defaultValue(param): - if param.type == "Integer": - return "0" - elif param.type == "Float": - return "0.0" - elif param.type == "Boolean": - return "false" - elif param.enum: - return "0" - -class Impl(FordXmlParser): - def make_requests_classes_header(self, out): - for interface_el in self.el_tree.findall('interface'): - request_responses = self.find_request_response_pairs_by_provider(interface_el, "sdl") - for (request, response) in request_responses: - request_full_name = interface_el.get('name') + '_' +request.get('name') - out.write('class ' + request_full_name + ': public HMIRequest {\n') - with CodeBlock(out) as output: - output.write('Q_OBJECT\n') - out.write(' public:\n') - with CodeBlock(out) as output: - output.write(request_full_name + '(QJSValue hmi_callback, QDBusInterface *interface, QList<QVariant> args, QString name):\n') - output.write(' HMIRequest(hmi_callback, interface, args, name) {}\n') - out.write(' private:\n') - with CodeBlock(out) as output: - output.write('QJSValueList fillArgsList();\n};\n\n') - - - def make_header_file(self, out): - out.write("namespace requests {\n") - out.write("class HMIRequest: public QObject {\n") - with CodeBlock(out) as output: - output.write('Q_OBJECT\n') - out.write('public:\n') - with CodeBlock(out) as output: - output.write('HMIRequest(QJSValue hmi_callback, QDBusInterface *interface, QList<QVariant> args, QString name );\n') - out.write('protected:\n') - with CodeBlock(out) as output: - output.write('virtual QJSValueList fillArgsList() = 0;\n') - output.write('QDBusPendingCallWatcher *watcher_;\n') - output.write('QJSValue hmi_callback_;\n\n') - output.write('template<typename T>\n') - output.write('QJSValue CreateQJSValue(T value) {\n') - output.write(' return QJSValue(value);\n') - output.write('}\n\n') - output.write('template<typename T>\n') - output.write('QJSValue CreateQJSValue(QList<T> value) {\n') - with CodeBlock(output) as output: - output.write('QJSValue array = hmi_callback_.engine()->newArray();\n') - output.write('int i = 0;\n') - output.write('foreach (T item, value) {\n') - output.write(' QJSValue value = CreateQJSValue(item);\n') - output.write(' array.setProperty(i, value);\n') - output.write(' ++i;\n') - output.write('}\n') - output.write('return array;\n') - output.write('}\n') - out.write('private:\n') - with CodeBlock(out) as output: - output.write('QDBusInterface *interface_;\n') - output.write('QList<QVariant> args_;\n') - out.write('public slots:\n') - with CodeBlock(out) as output: - output.write('void invokeCallback();\n') - out.write('};\n\n') - output.write('template<>\n') - output.write('QJSValue HMIRequest::CreateQJSValue(QStringList value);\n') - for (interface_name, struct_name) in self.structs: - out.write('template<>\n') - out.write('QJSValue HMIRequest::CreateQJSValue(Common_' + struct_name + ' value);\n\n') - impl.make_requests_classes_header(out) - out.write("} // namespace requests\n") - - - def qt_param_type(self, param): - if not param.mandatory: - param_copy = copy(param) - param_copy.mandatory = True - return "OptionalArgument< " + self.qt_param_type(param_copy) + " >" - if param.array: - param_copy = copy(param) - param_copy.array = False - if param.type == 'String': - return "QStringList" - return "QList< " + self.qt_param_type(param_copy) + " >" - if param.type == 'Integer' or param.enum: - return 'int' - elif param.type == 'String': - return 'QString' - elif param.type == 'Boolean': - return 'bool' - elif param.type == 'Float': - return 'double' - elif param.struct: - return "_".join(param.fulltype) - return "xxx" - - - def make_requests_methods_source(self, out): - for interface_el in self.el_tree.findall('interface'): - request_responses = self.find_request_response_pairs_by_provider(interface_el, "sdl") - for (request, response) in request_responses: - iface_name = interface_el.get('name') - request_full_name = iface_name + '_' +request.get('name') - out.write('QJSValueList ' + request_full_name + '::fillArgsList() {\n') - out.write(' QDBusPendingReply< ') - count = 0 - for param_el in response.findall('param'): - param = self.make_param_desc(param_el, iface_name) - out.write(self.qt_param_type(param)) - count += 1 - if count < len(response.findall('param')): - out.write(',') - out.write(' > reply = *watcher_;\n') - - with CodeBlock(out) as out: - out.write('QJSValueList qjsValueList;\n\n') - out.write('QJSValue param;\n\n') - count = 0 - for param_el in response.findall('param'): - if param_el.get('mandatory') == 'false': - out.write('if (reply.argumentAt<' + str(count) + '>().presence) {\n') - out.write(' param = CreateQJSValue(reply.argumentAt<' + str(count) + '>().val);\n') - out.write('} else {\n') - out.write(' param = QJSValue();\n') - out.write('}\n') - out.write('qjsValueList.append(param);\n') - else: - out.write('param = CreateQJSValue(reply.argumentAt<' + str(count) + '>());\n') - out.write('qjsValueList.append(param);\n') - count += 1 - out.write('return qjsValueList;\n') - out.write('}\n\n') - - - def make_source_file(self, out): - out.write("namespace requests {\n") - for interface_el in self.el_tree.findall('interface'): - for struct_el in interface_el.findall('struct'): - out.write('template<>\n') - out.write('QJSValue HMIRequest::CreateQJSValue(Common_' + struct_el.get('name') + ' value){\n') - with CodeBlock(out) as output: - output.write('QJSValue object = hmi_callback_.engine()->newObject();\n') - for param_el in struct_el.findall('param'): - param_name = param_el.get('name') - if param_el.get('mandatory') == 'true': - with CodeBlock(out) as output: - output.write('object.setProperty("' + param_name + '", CreateQJSValue(value.' + param_name + '));\n') - elif param_el.get('mandatory') == 'false': - with CodeBlock(out) as output: - output.write('object.setProperty("' + param_name + '", value.' + param_name + '.presence ? CreateQJSValue(value.' + param_name + '.val) : QJSValue());\n') - out.write('return object;\n') - out.write('}\n\n') - - - out.write('HMIRequest::HMIRequest(QJSValue hmi_callback, QDBusInterface *interface, QList<QVariant> args, QString name) :\n') - out.write(' hmi_callback_(hmi_callback), interface_(interface), args_(args) {\n') - with CodeBlock(out) as output: - output.write('QDBusPendingCall pcall = interface->asyncCallWithArgumentList(name, args);\n') - output.write('watcher_ = new QDBusPendingCallWatcher(pcall);\n') - output.write('QObject::connect(watcher_, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(invokeCallback()));\n}\n\n') - out.write('void HMIRequest::invokeCallback() {\n') - with CodeBlock(out) as output: - output.write('if (!hmi_callback_.isUndefined()) {\n') - with CodeBlock(output) as output: - output.write('QJSValueList qjsValueList;\n') - output.write('qjsValueList = this->fillArgsList();\n') - output.write('hmi_callback_.call(qjsValueList);\n') - output.write('}\n') - output.write('watcher_->deleteLater();\n') - output.write('this->deleteLater();\n}\n\n') - impl.make_requests_methods_source(out) - out.write("} // namespace requests\n") - - -arg_parser = ArgumentParser(description="Generator of Qt to QDbus C++ part") -arg_parser.add_argument('--infile', required=True, help="full name of input file, e.g. applink/src/components/interfaces/QT_HMI_API.xml") -arg_parser.add_argument('--version', required=False, help="Qt version 4.8.5 (default) or 5.1.0") -arg_parser.add_argument('--outdir', required=True, help="path to directory where output files request_to_sdl.h, request_to_sdl.cc will be saved") -args = arg_parser.parse_args() - -if args.version == "4.8.5": - prefix_class_item = 'Declarative' - invoke_type_connection = 'Direct' -elif args.version == "5.1.0": - prefix_class_item = 'Quick' - invoke_type_connection = 'BlockingQueued' - -header_name = 'hmi_requests.h' -source_name = 'hmi_requests.cc' - -in_tree = ElementTree.parse(args.infile) -in_tree_root = in_tree.getroot() - -impl = Impl(in_tree_root, 'com.ford.sdl.hmi') - -header_out = open(args.outdir + '/' + header_name, "w") -source_out = open(args.outdir + '/' + source_name, "w") - -header_out.write("// Warning! This file is generated by '%s'. Edit at your own risk.\n" % argv[0]) -header_out.write("""/** - * @file hmi_requests.h - * @brief Generated class that process requests from qtHMI - * - * This file is a part of HMI D-Bus layer. - */ -// Copyright (c) 2014, Ford Motor Company -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following -// disclaimer in the documentation and/or other materials provided with the -// distribution. -// -// Neither the name of the Ford Motor Company nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -""") -header_out.write("#ifndef SRC_COMPONENTS_QTHMI_QMLMODELQT5_HMIREQUESTS_\n"); -header_out.write("#define SRC_COMPONENTS_QTHMI_QMLMODELQT5_HMIREQUESTS_\n\n"); -header_out.write("#include <QObject>\n"); -header_out.write("#include <QJSValue>\n"); -header_out.write("#include <QDBusPendingCall>\n"); -header_out.write("#include <QDBusPendingCallWatcher>\n"); -header_out.write('#include <QDBusPendingReply>\n'); -header_out.write("#include <QDBusAbstractInterface>\n"); -header_out.write("#include <QDBusInterface>\n"); -header_out.write("#include <QJSEngine>\n"); - -header_out.write('#include "qml_dbus.h"\n\n'); - -impl.make_header_file(header_out) - -header_out.write("#endif // SRC_COMPONENTS_QTHMI_QMLMODELQT5_HMIREQUESTS_\n"); - -source_out.write("// Warning! This file is generated by '%s'. Edit at your own risk.\n" % argv[0]) -source_out.write("""/** - * @file hmi_requests.cc - * @brief Generated class that process requests from qtHMI - * - * This file is a part of HMI D-Bus layer. - */ -// Copyright (c) 2014, Ford Motor Company -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following -// disclaimer in the documentation and/or other materials provided with the -// distribution. -// -// Neither the name of the Ford Motor Company nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -""") -source_out.write('#include "hmi_requests.h"\n\n') -impl.make_source_file(source_out) diff --git a/src/components/dbus/codegen/make_introspection_c.py b/src/components/dbus/codegen/make_introspection_c.py deleted file mode 100755 index 22a53f308d..0000000000 --- a/src/components/dbus/codegen/make_introspection_c.py +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# @file make_introspection_c.py -# @brief Converts introspection.xml to C-string -# -# This file is a part of HMI D-Bus layer. -# -# Copyright (c) 2013, Ford Motor Company -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with the -# distribution. -# -# Neither the name of the Ford Motor Company nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -from argparse import ArgumentParser -from ford_xml_parser import FordXmlParser -from ford_xml_parser import node_name -from xml.etree import ElementTree -from os import path -from sys import argv - -class Impl(FordXmlParser): - def convert_to_introspection(self, out_el_tree): - for interface_el in self.el_tree.findall('interface'): - el = self.create_introspection_iface_el(interface_el, 'sdl') - if el is not None: - out_el_tree.append(el) - -arg_parser = ArgumentParser(description='Converts introspection.xml to C-string') -arg_parser.add_argument('--infile', required=True, help="Full name of input file, e.g. applink/src/components/interfaces/QT_HMI_API.xml") -arg_parser.add_argument('--outdir', required=True, help="Path to directory where output file introspection_xml.cc will be saved") -args = arg_parser.parse_args() - -if not path.isdir(args.outdir): - makedirs(args.outdir) - -out_file = open(args.outdir + '/' + 'introspection_xml.cc', "w") - -in_tree = ElementTree.parse(args.infile) -in_tree_root = in_tree.getroot() -out_tree_root = ElementTree.Element('node', attrib={'name':node_name}) - -impl = Impl(in_tree_root, 'com.ford.hmi.sdl') -impl.convert_to_introspection(out_tree_root) - -introspection_string = '<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">' -introspection_string += "\n" -introspection_string += ElementTree.tostring(out_tree_root) - -out_file.write("// Warning! This file is generated by '%s'. Edit at your own risk.\n" % argv[0]) -out_file.write("""/** - * @file instrospections_xml.cc - * @brief D-Bus introspection XML as C-string - * - * This file is a part of HMI D-Bus layer. - */ -// Copyright (c) 2013, Ford Motor Company -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following -// disclaimer in the documentation and/or other materials provided with the -// distribution. -// -// Neither the name of the Ford Motor Company nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -""") - -out_file.write("char introspection_xml[] = {") - -cnt = 0 -for char in introspection_string: - if cnt % 12 == 0: - out_file.write("\n ") - else: - out_file.write(" ") - out_file.write("0x%02x," % ord(char)) - cnt = cnt + 1 - -out_file.write(" 0x00\n") -out_file.write("};") - diff --git a/src/components/dbus/codegen/make_message_descriptions.py b/src/components/dbus/codegen/make_message_descriptions.py deleted file mode 100755 index 0079666392..0000000000 --- a/src/components/dbus/codegen/make_message_descriptions.py +++ /dev/null @@ -1,273 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# @file make_message_descriptions.py -# @brief Generates HMI API message descriptions for D-Bus -# -# This file is a part of HMI D-Bus layer. -# -# Copyright (c) 2013, Ford Motor Company -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with the -# distribution. -# -# Neither the name of the Ford Motor Company nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -from argparse import ArgumentParser -from xml.etree import ElementTree -from copy import copy -from ford_xml_parser import FordXmlParser -from os import path -from sys import argv - -namespace_name = 'ford_message_descriptions' -namespace = namespace_name + '::' - - -class Impl(FordXmlParser): - def write_param_definition(self, param_var_name, param, out): - if param.array: - tmp_param = copy(param) - tmp_param.array = False - tmp_param.mandatory = True - dbus_sig = self.convert_to_dbus_type(tmp_param) - self.write_param_definition(param_var_name + '_array', tmp_param, out) - - if param.array: out.write('const ' + namespace + 'ArrayDescription ') - elif param.struct: out.write('const ' + namespace + 'StructDescription ') - else: out.write('const ' + namespace + 'ParameterDescription ') - - out.write(param_var_name + " = {\n") - - if param.struct or param.array: - out.write(" {\n") - shift = ' ' * 4 - else: - shift = ' ' * 2 - - out.write(shift + "\"" + param.name + "\",\n") - - if param.array: - out.write(shift + namespace + "Array,\n") - elif param.struct: - out.write(shift + namespace + "Struct,\n") - elif param.enum: - out.write(shift + namespace + "Enum,\n") - else: - out.write(shift + namespace + param.type + ",\n") - - if param.mandatory: - out.write(shift + "true\n") - else: - out.write(shift + "false\n") - - if param.struct or param.array: - out.write(" },\n") - if param.array: - out.write(" (const " + namespace + "ParameterDescription*)&" + param_var_name + "_array,\n") - out.write(" \"" + dbus_sig + "\"\n") - elif param.struct: - out.write(" Structs::" + param.fulltype[0] + "__" + param.fulltype[1] + "__parameters\n") - out.write("};\n") - - - def write_struct_params_declarations(self, out): - out.write("struct Structs {\n"); - for (interface, name), params in self.structs.iteritems(): - params_var_name = interface + '__' + name + '__parameters' - out.write(" static const " + namespace + "ParameterDescription* " + params_var_name + "[];\n") - out.write("};\n\n") - - - def write_enum_entries_declarations(self, out): - out.write("struct Enums {\n"); - for interface, name in self.enums: - entries_var_name = interface + '__' + name + '__entries' - out.write(" static const " + namespace + "EnumDescription::Entry* " + entries_var_name + "[];\n") - out.write("};\n\n") - - - def write_parameters(self, params, out, name): - n = 1 - for param in params: - param_var_name = name + str(n) - n = n + 1 - self.write_param_definition(param_var_name, param, out) - - - def write_struct_params_definitions(self, out): - for (interface, name), params in self.structs.iteritems(): - param_var_name = interface + '__' + name + '__parameter' - self.write_parameters(params, out, param_var_name) - params_var_name = 'Structs::' + interface + '__' + name + '__parameters' - out.write("const " + namespace + "ParameterDescription* " + params_var_name + "[] = {\n") - for n in range(1, len(params) + 1): - name = param_var_name + str(n) - out.write(" (const " + namespace + "ParameterDescription*)&" + name + ",\n") - out.write( " NULL };\n\n") - - - def write_enum_entries_definitions(self, out): - for (interface, name), enum_el in self.enums.iteritems(): - n = 1 - for element_el in enum_el.findall('element'): - entry_var_name = interface + '__' + name + '__entry' + str(n) - value = element_el.get("value") - if value is None: - value = str(n) - out.write(namespace + "EnumDescription::Entry " + entry_var_name + " = {\"" + element_el.get("name") + "\", " + value + "};\n") - n = n + 1 - - entries_var_name = "Enums::" + interface + '__' + name + '__entries' - out.write("const " + namespace + "EnumDescription::Entry* " + entries_var_name + "[] = {\n") - for n in range(1, len(enum_el.findall('element')) + 1): - entry_var_name = interface + '__' + name + '__entry' + str(n) - out.write(" &" + entry_var_name + ",\n") - out.write(" NULL };\n\n") - - - def write_message_definition(self, message_el, interface, out): - name = message_el.get('name') - messagetype = message_el.get('messagetype') - params = list() - for param_el in message_el.findall('param'): - param_desc = self.make_param_desc(param_el, interface) - params.append(param_desc) - param_var_name = interface + '__' + name + '__' + messagetype + '__parameter' - self.write_parameters(params, out, param_var_name) - - params_var_name = param_var_name + 's' - out.write("const " + namespace + "ParameterDescription* " + params_var_name + "[] = {\n") - for n in range(1, len(params) + 1): - param_name = param_var_name + str(n) - out.write(" (const " + namespace + "ParameterDescription*)&" + param_name + ",\n") - out.write(" NULL };\n") - - message_desc_name = interface + '__' + name + '__' + messagetype - out.write("const " + namespace + "MessageDescription " + message_desc_name + " = {\n") - out.write(" \"" + interface + "\",\n") - out.write(" \"" + name + "\",\n") - out.write(" hmi_apis::messageType::" + messagetype + ",\n") - out.write(" hmi_apis::FunctionID::" + interface + "_" + name + ",\n") - out.write(" " + params_var_name + "\n") - out.write("};\n\n") - - - def write_message_definitions(self, out): - for interface_el in self.el_tree.findall('interface'): - interface = interface_el.get('name') - message_els = interface_el.findall('function') - for message_el in message_els: - self.write_message_definition(message_el, interface, out) - - - def make_message_descriptions(self, out): - self.write_struct_params_declarations(out) - #self.write_enum_entries_declarations(out) - self.write_struct_params_definitions(out) - #self.write_enum_entries_definitions(out) - self.write_message_definitions(out) - - - def make_message_array(self, out): - out.write("const MessageDescription* message_descriptions[] = {\n") - for interface_el in self.el_tree.findall('interface'): - interface = interface_el.get('name') - message_els = interface_el.findall('function') - for message_el in message_els: - name = message_el.get('name') - messagetype = message_el.get('messagetype') - message_desc_name = interface + '__' + name + '__' + messagetype - out.write(" &" + message_desc_name + ",\n") - out.write(" NULL\n") - out.write("};\n") - - -arg_parser = ArgumentParser(description="Generates HMI API message descriptions for D-Bus on SDL core side") -arg_parser.add_argument('--infile', required=True, help="full name of input file, e.g. applink/src/components/interfaces/QT_HMI_API.xml") -arg_parser.add_argument('--outdir', required=True, help="path to directory where output file message_descriptions.cc will be saved") -args = arg_parser.parse_args() - -if not path.isdir(args.outdir): - makedirs(args.outdir) - -outfile = 'message_descriptions.cc' - -in_tree = ElementTree.parse(args.infile) -in_tree_root = in_tree.getroot() - -impl = Impl(in_tree_root) - -out = open(args.outdir + "/" + outfile, "w") - -out.write("// Warning! This file is generated by '%s'. Edit at your own risk.\n" % argv[0]) -out.write("""/** - * @file message_descriptions.cc - * @brief Generated HMI API message descriptions for D-Bus - * - * This file is a part of HMI D-Bus layer. - */ -// Copyright (c) 2013, Ford Motor Company -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following -// disclaimer in the documentation and/or other materials provided with the -// distribution. -// -// Neither the name of the Ford Motor Company nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -""") - -out.write("#include \"dbus/message_descriptions.h\"\n\n"); -out.write("namespace {\n\n"); -impl.make_message_descriptions(out) -out.write("}\n\n"); - -out.write("namespace " + namespace_name + " {\n\n"); -impl.make_message_array(out) -out.write("}\n\n"); - diff --git a/src/components/dbus/codegen/make_notifications_qml.py b/src/components/dbus/codegen/make_notifications_qml.py deleted file mode 100755 index 3c173e8b4f..0000000000 --- a/src/components/dbus/codegen/make_notifications_qml.py +++ /dev/null @@ -1,387 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# @file make_qml_dbus_cpp.py -# @brief Generator of QML to QDbus C++ part -# -# This file is a part of HMI D-Bus layer. -# -# Copyright (c) 2014, Ford Motor Company -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with the -# distribution. -# -# Neither the name of the Ford Motor Company nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -from argparse import ArgumentParser -import os.path -from sys import argv -from xml.etree import ElementTree -from copy import copy -from ford_xml_parser import FordXmlParser, ParamDesc -from code_formatter import CodeBlock - -class Notifications_qml(FordXmlParser): - #Used for qt signal names, because qt signals cannot begin with a capital letter - def first_letter_to_lower_case(self, s): - if len(s) == 0: - return s - else: - return s[0].lower() + s[1:] - - def make_header(self, out): - out.write("class SdlProxy: public Item {\n") - with CodeBlock(out) as out: - out.write("Q_OBJECT\n") - out.write("Q_DISABLE_COPY(SdlProxy)\n") - out.write("public:\n") - out.write("explicit SdlProxy(Item* parent = 0);\n") - out.write("private:\n") - out.write("QDBusInterface *sdlBasicCommunicationInterface;\n") - out.write("signals:\n") - for interface_el in self.el_tree.findall('interface'): - iface_name = interface_el.get('name') - notifications = self.find_notifications_by_provider(interface_el, "sdl") - for notification_el in notifications: - with CodeBlock(out) as out: - out.write("void %s(" % self.first_letter_to_lower_case( notification_el.get("name")) ) - param_el_count = 1 - list_of_params = notification_el.findall("param") - list_of_params_len = len(list_of_params) - for param_el in list_of_params: - param = self.make_param_desc(param_el, iface_name) - out.write("QVariant %s" % param_el.get("name")) - if param_el_count < list_of_params_len: - out.write(", ") - param_el_count += 1 - out.write(");\n") - with CodeBlock(out) as out: - out.write("private slots:\n") - for interface_el in self.el_tree.findall('interface'): - iface_name = interface_el.get('name') - notifications = self.find_notifications_by_provider(interface_el, "sdl") - for notification_el in notifications: - with CodeBlock(out) as out: - out.write("void slot_%s(" % notification_el.get("name")) - param_el_count = 1 - list_of_params = notification_el.findall("param") - list_of_params_len = len(list_of_params) - for param_el in list_of_params: - param = self.make_param_desc(param_el, iface_name) - out.write("%s %s" % (self.qt_param_type(param), param_el.get("name"))) - if param_el_count < list_of_params_len: - out.write(", ") - param_el_count += 1 - out.write(");\n") - out.write("};\n") - - - def qt_param_type(self, param): - if not param.mandatory: - param_copy = copy(param) - param_copy.mandatory = True - return "OptionalArgument< " + self.qt_param_type(param_copy) + " >" - if param.array: - param_copy = copy(param) - param_copy.array = False - if param.type == 'String': - return "QStringList" - return "QList< " + self.qt_param_type(param_copy) + " >" - if param.type == 'Integer' or param.enum: - return 'int' - elif param.type == 'String': - return 'QString' - elif param.type == 'Boolean': - return 'bool' - elif param.type == 'Float': - return 'double' - elif param.struct: - return "_".join(param.fulltype) - else: - raise RuntimeError('Unknown type: ' + param.type) - - - def qml_param_type(self, param): - if not param.mandatory: - return "QVariant" - if param.array: - return "QVariant" - if param.type == 'Integer' or param.enum: - return 'int' - elif param.type == 'String': - return 'QString' - elif param.type == 'Boolean': - return 'bool' - elif param.type == 'Float': - return 'double' - elif param.struct: - return "QVariant" - else: - raise RuntimeError('Unknown type: ' + param.type) - - - def make_source(self, out): - def qml_args(variable_name_needed): - param_el_count = 1 - list_of_params = notification_el.findall("param") - list_of_params_len = len(list_of_params) - for param_el in list_of_params: - param = self.make_param_desc(param_el, iface_name) - if variable_name_needed: - out.write("%s %s" % (self.qt_param_type(param), param_el.get("name"))) - else: - out.write("%s" % self.qt_param_type(param)) - if param_el_count < list_of_params_len: - out.write(", ") - param_el_count += 1 - out.write("SdlProxy::SdlProxy(Item *parent): Item(parent) {\n") - for interface_el in self.el_tree.findall('interface'): - iface_name = interface_el.get('name') - notifications = self.find_notifications_by_provider(interface_el, "sdl") - for notification_el in notifications: - notification_name = notification_el.get('name') - with CodeBlock(out) as out: - out.write("QDBusConnection::sessionBus().connect(\n") - with CodeBlock(out) as out: - out.write("\"com.ford.sdl.core\", \"/\", \"com.ford.sdl.core.%s\",\n" % iface_name) - out.write("\"%s\", this, SLOT(slot_%s(" % (notification_name, notification_el.get("name"))) - qml_args(variable_name_needed = False) - out.write(")));\n") - out.write("}\n\n") - for interface_el in self.el_tree.findall('interface'): - iface_name = interface_el.get('name') - notifications = self.find_notifications_by_provider(interface_el, "sdl") - for notification_el in notifications: - notific_full_name = interface_el.get("name") + "_" + notification_el.get("name") - out.write("void SdlProxy::slot_%s(" % notification_el.get("name")) - qml_args(variable_name_needed = True) - out.write(") {\n") - with CodeBlock(out) as out: - out.write("LOG4CXX_TRACE(logger_, \"ENTER\");\n\n") - for param_el in notification_el.findall("param"): - param = self.make_param_desc(param_el, iface_name) - tmp_param_name = param.name + "_qvariant" - out.write("QVariant %s;\n" % tmp_param_name) - out.write("%s = ValueToVariant(%s);\n" % (tmp_param_name, param.name)) - self.write_param_validation(param, param.name, "\nLOG4CXX_ERROR(logger_, \"%s in %s out of bounds\")" % (param.name, notific_full_name), out) - out.write("\n") - out.write("emit %s(" % self.first_letter_to_lower_case( notification_el.get("name")) ) - param_el_count = 1 - list_of_params = notification_el.findall("param") - list_of_params_len = len(list_of_params) - for param_el in list_of_params: - param = self.make_param_desc(param_el, iface_name) - out.write("%s" % param.name + "_qvariant") - if param_el_count < list_of_params_len: - out.write(", ") - param_el_count += 1 - out.write(");\n") - with CodeBlock(out) as out: - out.write("LOG4CXX_TRACE(logger_, \"EXIT\");\n") - out.write("}\n\n") - - - - def write_param_validation(self, param, param_name, fail_statement, out, level=0): - if not param.mandatory and (param.restricted or param.restrictedArray or (param.struct and any(map(lambda x: x.restricted, self.structs[param.fulltype])))): - out.write("if (%s.presence) {\n" % param_name) - param_copy = copy(param) - param_copy.mandatory = True - with CodeBlock(out) as out: - self.write_param_validation(param_copy, param_name + ".val", fail_statement, out, level+1) - out.write("}\n") - elif param.array: - if param.minSize > 0: - out.write("if ({0}.count() < {1}) {{".format(param_name, param.minSize)) - with CodeBlock(out) as out: - out.write("{0};\n".format(fail_statement)) - out.write("}\n") - if param.maxSize != None: - out.write("if ({0}.count() > {1}) {{".format(param_name, param.maxSize)) - with CodeBlock(out) as out: - out.write("{0};\n".format(fail_statement)) - out.write("}\n") - if param.restricted: - out.write('for ({0}::const_iterator it_{2} = {1}.begin(); it_{2} != {1}.end(); ++it_{2}) {{\n'.format(self.qt_param_type(param), param_name, level)) - with CodeBlock(out) as out: - param_copy = copy(param) - param_copy.array = False - self.write_param_validation(param_copy, "(*it_{0})".format(level), fail_statement, out, level+1) - out.write("}\n") - elif param.struct: - for p in self.structs[param.fulltype]: - self.write_param_validation(p, "{0}.{1}".format(param_name, p.name), fail_statement, out, level+1) - elif param.type == "Integer" or param.type == "Float": - conditions = [] - if (param.minValue != None): - conditions.append("(%s < %s)" % (param_name, param.minValue)) - if (param.maxValue != None): - conditions.append("(%s > %s)" % (param_name, param.maxValue)) - if conditions: - out.write('if (%s) {' % ' || '.join(conditions)) - with CodeBlock(out) as out: - out.write('%s;\n' % fail_statement) - out.write("}\n") - elif param.type == "String": - conditions = [] - if (param.minLength > 0): - conditions.append("(%s.size() < %s)" % (param_name, param.minLength)) - if (param.maxLength > 0): - conditions.append("(%s.size() > %s)" % (param_name, param.maxLength)) - if conditions: - out.write('if (%s) {' % ' || '.join(conditions)) - with CodeBlock(out) as out: - out.write('%s;\n' % (fail_statement)) - out.write("}\n") - - -#QVarian name; -#if (ttsName.presence) { - - - -arg_parser = ArgumentParser(description="Generator of classes which Qt to QDbus C++ part") -arg_parser.add_argument('--infile', required=True, help="full name of input file, e.g. applink/src/components/interfaces/QT_HMI_API.xml") -arg_parser.add_argument('--version', required=False, help="Qt version 4.8.5 (default) or 5.1.0") -arg_parser.add_argument('--outdir', required=True, help="path to directory where output files request_to_sdl.h, request_to_sdl.cc will be saved") -args = arg_parser.parse_args() - - -if args.version == "4.8.5": - prefix_class_item = 'Script' - invoke_type_connection = 'Direct' -elif args.version == "5.1.0": - prefix_class_item = 'JS' - invoke_type_connection = 'BlockingQueued' -else: - prefix_class_item = 'JS' - invoke_type_connection = 'BlockingQueued' - -header_name = 'sdl_proxy.h' -source_name = 'sdl_proxy.cc' - -in_tree = ElementTree.parse(args.infile) -in_tree_root = in_tree.getroot() - -impl = Notifications_qml(in_tree_root, 'com.ford.sdl.hmi') - -header_out = open(args.outdir + '/' + header_name, "w") -source_out = open(args.outdir + '/' + source_name, "w") - -header_out.write("// Warning! This file is generated by '%s'. Edit at your own risk.\n" % argv[0]) -header_out.write(""" -/* - Copyright (c) 2014, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ -""") -header_out.write("#ifndef SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_SDL_PROXY_H_\n") -header_out.write("#define SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_SDL_PROXY_H_\n\n") -header_out.write("#include \"qml_dbus.h\"\n") -header_out.write("#include \"qt_version.h\"\n\n") -header_out.write("#include <QtCore/QVariant>\n") -header_out.write("#include <QtDBus/QDBusInterface>\n") -header_out.write("#if QT_4\n") -header_out.write("#include <QtDeclarative/QDeclarativeItem>\n") -header_out.write("typedef QDeclarativeItem Item;\n") -header_out.write("#elif QT_5\n") -header_out.write("#include <QtQuick/QQuickItem>\n") -header_out.write("typedef QQuickItem Item;\n") -header_out.write("#endif // QT_VERSION\n") - -impl.make_header(header_out) - -header_out.write("#endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_REQUEST_TO_SDL_H_") - - -source_out.write("// Warning! This file is generated by '%s'. Edit at your own risk.\n" % argv[0]) -source_out.write(""" -/* - Copyright (c) 2014, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -""") - -source_out.write("#include \"sdl_proxy.h\"\n") -source_out.write("#include \"utils/logger.h\"\n") -source_out.write("CREATE_LOGGERPTR_GLOBAL(logger_, \"DBusPlugin\")\n\n") - -impl.make_source(source_out) diff --git a/src/components/dbus/codegen/make_qml_dbus_cpp.py b/src/components/dbus/codegen/make_qml_dbus_cpp.py deleted file mode 100755 index f40bc74df8..0000000000 --- a/src/components/dbus/codegen/make_qml_dbus_cpp.py +++ /dev/null @@ -1,736 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# @file make_qml_dbus_cpp.py -# @brief Generator of QML to QDbus C++ part -# -# This file is a part of HMI D-Bus layer. -# -# Copyright (c) 2013, Ford Motor Company -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with the -# distribution. -# -# Neither the name of the Ford Motor Company nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -from argparse import ArgumentParser -import os.path -from sys import argv -from xml.etree import ElementTree -from copy import copy -from ford_xml_parser import FordXmlParser, ParamDesc -from code_formatter import CodeBlock - -prefix_class_item = 'Declarative' -invoke_type_connection = 'Direct' - -def defaultValue(param): - if param.type == "Integer": - return "0" - elif param.type == "Float": - return "0.0" - elif param.type == "Boolean": - return "false" - elif param.enum: - return "0" - -class Impl(FordXmlParser): - def make_dbus_type_declarations(self, out): - for struct in self.structs.items(): - self.write_struct_declaration(struct, out) - - def make_dbus_metatype_declarations(self, out): - for struct in self.structs.items(): - self.write_struct_metatype_declaration(struct, out) - - - def write_struct_declaration(self, ((iface, name), params), out): - struct_name = "{0}_{1}".format(iface, name) - out.write("struct {0} {{\n".format(struct_name)) - with CodeBlock(out) as out: - for param in params: - out.write("{0} {1};\n".format(self.qt_param_type(param), param.name)) - out.write("{0}()\n".format(struct_name)) - initializersList = map(lambda x: "{0}({1})".format(x.name, defaultValue(x)), [p for p in params if p.type != "String" and not p.struct and not p.array]) - if initializersList: - out.write(": " + ",\n ".join(initializersList)) - - out.write("{ }\n") - - out.write("};\n") - out.write('QDBusArgument& operator << (QDBusArgument&, const ' + struct_name + "&);\n") - out.write('const QDBusArgument& operator >> (const QDBusArgument&, ' + struct_name + "&);\n") - out.write('void PutArgToMap(QVariantMap& map, const char* name, const ' + struct_name + "& v);\n") - out.write('QVariant ValueToVariant(const ' + struct_name + "& v);\n") - out.write('QVariant ValueToVariant(const QList<' + struct_name + " >& v);\n") - out.write('bool GetArgFromMap(const QVariantMap& map, const char* name, ' + struct_name + "& v);\n") - out.write('bool VariantToValue(const QVariant& variant, ' + struct_name + "& v);\n") - out.write('bool VariantToValue(const QVariant& variant, QList<' + struct_name + " >& v);\n") - - - def write_struct_metatype_declaration(self, ((iface, name), params), out): - struct_name = iface + '_' + name - out.write('Q_DECLARE_METATYPE(' + struct_name + ")\n") - out.write('Q_DECLARE_METATYPE(OptionalArgument<' + struct_name + ">)\n") - out.write('Q_DECLARE_METATYPE(QList<' + struct_name + ">)\n") - out.write('Q_DECLARE_METATYPE(OptionalArgument<QList<' + struct_name + "> >)\n\n") - - - def make_dbus_type_definitions(self, out): - for struct in self.structs.items(): - self.write_struct_definition(struct, out) - - def write_struct_definition(self, ((iface, name), params), out): - struct_name = iface + '_' + name - - out.write('QDBusArgument& operator << (QDBusArgument& arg, const ' + struct_name + "& v) {\n") - with CodeBlock(out) as out: - out.write("arg.beginStructure();\n") - for param in params: - out.write("arg << v.{0};\n".format(param.name)) - out.write("arg.endStructure();\n") - out.write("return arg;\n") - out.write("}\n\n") - - out.write('const QDBusArgument& operator >> (const QDBusArgument& arg, ' + struct_name + "& v) {\n") - with CodeBlock(out) as out: - out.write("arg.beginStructure();\n") - for param in params: - out.write("arg >> v.{0};\n".format(param.name)) - out.write("arg.endStructure();\n") - out.write("return arg;\n") - out.write("}\n\n") - - out.write('QVariant ValueToVariant(const ' + struct_name + "& v) {\n") - with CodeBlock(out) as out: - out.write("QVariantMap map;\n") - for param in params: - out.write("""PutArgToMap(map, "{0}", v.{0});\n""".format(param.name)) - out.write("return QVariant::fromValue(map);\n") - out.write("}\n\n") - - out.write('QVariant ValueToVariant(const QList<' + struct_name + ">& v) {\n") - with CodeBlock(out) as out: - out.write("QList<QVariant> ret;\n") - out.write("for (QList<{0}>::const_iterator i = v.begin(); i != v.end(); ++i)\n".format(struct_name)) - with CodeBlock(out) as out: - out.write("ret.append(ValueToVariant(*i));\n") - out.write("return QVariant::fromValue(ret);\n") - out.write("}\n\n") - - out.write('void PutArgToMap(QVariantMap& map, const char* name, const ' + struct_name + "& v) {\n") - with CodeBlock(out) as out: - out.write("map.insert(name, ValueToVariant(v));\n") - out.write("}\n\n") - - out.write('bool VariantToValue(const QVariant& variant, ' + struct_name + "& v) {\n") - with CodeBlock(out) as out: - out.write("if (variant.type() != QVariant::Map) {\n") - with CodeBlock(out) as out: - out.write("""LOG4CXX_ERROR(logger_, "Input argument isn't a map");\n""") - out.write("return false;\n") - out.write("}\n") - out.write("QVariantMap map = variant.toMap();\n") - for param in params: - out.write("if (!GetArgFromMap(map, \"" + param.name + "\", v." + param.name + ")) return false;\n") - out.write("return true;\n") - out.write("}\n\n") - - out.write('bool VariantToValue(const QVariant& variant, QList<' + struct_name + ">& v) {\n") - with CodeBlock(out) as out: - out.write("if (variant.type() != QVariant::List) {\n") - with CodeBlock(out) as out: - out.write("""LOG4CXX_ERROR(logger_, "Input argument isn't a list");\n""") - out.write("return false;\n") - out.write("}\n") - out.write("QList<QVariant> list = variant.toList();\n") - out.write("for (QList<QVariant>::const_iterator i = list.begin(); i != list.end(); ++i) {\n"); - with CodeBlock(out) as out: - out.write(struct_name + " s;\n"); - out.write("if (!VariantToValue(*i, s)) return false;\n"); - out.write("v.append(s);\n"); - out.write("}\n") - out.write("return true;\n") - out.write("}\n\n") - - out.write('bool GetArgFromMap(const QVariantMap& map, const char* name, ' + struct_name + "& v) {\n") - with CodeBlock(out) as out: - out.write("QVariantMap::const_iterator it = map.find(name);\n") - out.write("if (map.end() == it) {\n") - with CodeBlock(out) as out: - out.write("""LOG4CXX_WARN(logger_, "Argument '" << name << "' not found");\n""") - out.write("return false;\n") - out.write("}\n") - out.write("if (it->type() != QVariant::Map) {\n") - with CodeBlock(out) as out: - out.write("""LOG4CXX_ERROR(logger_, "Argument '" << name << "' isn't a map");\n""") - out.write("return false;\n") - out.write("}\n") - out.write("const QVariantMap& inmap = it->toMap();\n") - for param in params: - out.write("if (!GetArgFromMap(inmap, \"" + param.name + "\", v." + param.name + ")) return false;\n") - out.write("return true;\n") - out.write("}\n\n") - - def write_param_validation(self, param, param_name, fail_statement, out, level=0): - if not param.mandatory and (param.restricted or param.restrictedArray or (param.struct and any(map(lambda x: x.restricted, self.structs[param.fulltype])))): - out.write("if (%s.presence) {\n" % param_name) - param_copy = copy(param) - param_copy.mandatory = True - with CodeBlock(out) as out: - self.write_param_validation(param_copy, param_name + ".val", fail_statement, out, level+1) - out.write("}\n") - elif param.array: - if param.minSize > 0: - out.write("if ({0}.count() < {1}) {{ {2}; }}\n".format(param_name, param.minSize, fail_statement)) - if param.maxSize != None: - out.write("if ({0}.count() > {1}) {{ {2}; }}\n".format(param_name, param.maxSize, fail_statement)) - if param.restricted: - out.write('for ({0}::const_iterator it_{2} = {1}.begin(); it_{2} != {1}.end(); ++it_{2}) {{\n'.format(self.qt_param_type(param), param_name, level)) - with CodeBlock(out) as out: - param_copy = copy(param) - param_copy.array = False - self.write_param_validation(param_copy, "(*it_{0})".format(level), fail_statement, out, level+1) - out.write("}\n") - elif param.struct: - for p in self.structs[param.fulltype]: - self.write_param_validation(p, "{0}.{1}".format(param_name, p.name), fail_statement, out, level+1) - elif param.type == "Integer" or param.type == "Float": - conditions = [] - if (param.minValue != None): - conditions.append("(%s < %s)" % (param_name, param.minValue)) - if (param.maxValue != None): - conditions.append("(%s > %s)" % (param_name, param.maxValue)) - if conditions: - out.write('if (%s) { %s; }\n' % (' || '.join(conditions), fail_statement)) - elif param.type == "String": - conditions = [] - if (param.minLength > 0): - conditions.append("(%s.size() < %s)" % (param_name, param.minLength)) - if (param.maxLength > 0): - conditions.append("(%s.size() > %s)" % (param_name, param.maxLength)) - if conditions: - with CodeBlock(out) as out: - out.write('if (%s) { %s;\n }\n' % (' || '.join(conditions), fail_statement)) - - def qt_param_type(self, param): - if not param.mandatory: - param_copy = copy(param) - param_copy.mandatory = True - return "OptionalArgument< " + self.qt_param_type(param_copy) + " >" - if param.array: - param_copy = copy(param) - param_copy.array = False - if param.type == 'String': - return "QStringList" - return "QList< " + self.qt_param_type(param_copy) + " >" - if param.type == 'Integer' or param.enum: - return 'int' - elif param.type == 'String': - return 'QString' - elif param.type == 'Boolean': - return 'bool' - elif param.type == 'Float': - return 'double' - elif param.struct: - return "_".join(param.fulltype) - return "xxx" - - - def from_variant_func_name(self, param, interface): - prefix = '' - if not param.mandatory: - param_copy = copy(param) - param_copy.mandatory = True - return 'opt_' + self.from_variant_func_name(param_copy, interface) - if param.array: - param_copy = copy(param) - param_copy.array = False - return 'arr_' + self.from_variant_func_name(param_copy, interface) - - if param.type in ['Integer', 'String', 'Boolean', 'Float']: - param_type = param.type - else: - param_type = param.type.split('.') - if len(param_type) > 1: - param_type = (param_type[0], param_type[1]) - else: - param_type = (interface, param_type[0]) - if param_type in self.structs: - param_type = param_type[0] + '_' + param_type[1] - elif param_type in self.enums: - param_type = 'Integer' - return param_type + '_from_variant' - - - def make_method_signature(self, request, response, interface, add_classname): - in_params = [self.make_param_desc(x, interface) for x in request.findall('param')] - out_params = [self.make_param_desc(x, interface) for x in response.findall('param')] - - signature_len = len(''.join(map(lambda x: self.convert_to_dbus_type(x), in_params + out_params))) - if signature_len > 255: - raise RuntimeError("Too long signature of {0} method. Maximum valid length is 255, actual is {1}", request.get('name'), signature_len) - - return "int {0}{1} ({2}{3}const QDBusMessage& message, QString& userMessage_out{4}{5})".format( - interface + "Adaptor::" if add_classname else "", - request.get('name'), - ", ".join(map(lambda x: "const {0}& {1}_in".format(self.qt_param_type(x), x.name), in_params)), - ", " if in_params else "", - ", " if out_params else "", - ", ".join(map(lambda x: "{0}& {1}_out".format(self.qt_param_type(x), x.name), out_params))) - - - def make_signal_signature(self, signal, interface, add_void): - params = signal.findall('param') - if add_void: - retstr = 'void ' - else: - retstr = '' - retstr = retstr + signal.get('name') + '(' - params_num = len(params) - for i in range(0, params_num): - param_desc = self.make_param_desc(params[i], interface) - param_type = self.qt_param_type(param_desc) - retstr = retstr + param_type + ' ' + param_desc.name - if i <> params_num - 1: retstr = retstr + ", " - retstr = retstr + ')' - return retstr - - - def make_qml_signal_signature(self, signal, interface, name, short=False, add_classname=False): - params = signal.findall('param') - if short: - retstr = '' - else: - retstr = 'void ' - if add_classname: - retstr = retstr + interface + 'Adaptor::' - retstr = retstr + name + '(' - params_num = len(params) - for i in range(0, params_num): - param_desc = self.make_param_desc(params[i], interface) - if param_desc.struct or param_desc.array or not param_desc.mandatory: typ = 'QVariant' - elif param_desc.type == 'Integer' or param_desc.enum: typ = 'int' - elif param_desc.type == 'Boolean': typ = 'bool' - elif param_desc.type == 'Float': typ = 'double' - elif param_desc.type == 'String': typ = 'QString' - else: typ = 'QVariant' - retstr = retstr + typ - if not short: retstr = retstr + ' ' + param_desc.name - if i <> params_num - 1: retstr = retstr + ", " - retstr = retstr + ')' - return retstr - - - def write_adaptor_declaration(self, interface_el, notifications, request_responses, out): - global prefix_class_item - def glue_strings(strings): - ret = list() - curstr = '' - for str in strings: - curstr = curstr + str - if(str[-1] == '>'): - ret.append(curstr) - curstr = '' - return ret - ifacename = interface_el.get('name') - out.write("class " + ifacename + "Adaptor : public QDBusAbstractAdaptor {\n"); - out.write(" Q_OBJECT\n"); - out.write(" Q_CLASSINFO(\"D-Bus Interface\", \"" + self.interface_path + '.' + ifacename + "\")\n"); - out.write(" Q_CLASSINFO(\"D-Bus Introspection\",\n"); - introspection_el = self.create_introspection_iface_el(interface_el, 'hmi') - introspection = glue_strings(ElementTree.tostringlist(introspection_el)) - for str in introspection: - str = str.replace('"', '\\"') - out.write('"' + str + '"' + "\n") - out.write(" )\n") - out.write(" public:\n") - out.write(" explicit " + ifacename + "Adaptor(QObject *parent = 0);\n") - out.write(" void SetApi(Q%sItem*);\n" % prefix_class_item) - out.write(" DBusController *dbusController;\n") - out.write(" public slots:\n") - for (request, response) in request_responses: - signature = self.make_method_signature(request, response, ifacename, False) - out.write(" " + signature + ";\n") - out.write(" signals:\n") - for n in notifications: - signature = self.make_signal_signature(n, ifacename, True) - out.write(" " + signature + ";\n") - out.write(" private slots:\n") - for n in notifications: - signature = self.make_qml_signal_signature(n, ifacename, n.get('name') + '_qml', False) - out.write(" " + signature + ";\n") - out.write(" private:\n") - out.write(" Q%sItem* api_;\n" % prefix_class_item) - out.write("};\n\n"); - - def write_adaptor_definition(self, interface_el, notifications, request_responses, out): - global prefix_class_item - iface_name = interface_el.get('name') - classname = iface_name + 'Adaptor' - out.write("{0}::{0}(QObject* parent) : QDBusAbstractAdaptor(parent) {{}}\n".format(classname)) - - out.write("void {0}::SetApi(Q{1}Item* api) {{\n".format(classname, prefix_class_item)) - with CodeBlock(out) as out: - out.write("api_ = api;\n") - for n in notifications: - signame = n.get('name') - signame = signame[:1].lower() + signame[1:] - slotname = n.get('name') + '_qml' - sig_signature = self.make_qml_signal_signature(n, iface_name, signame, True) - slot_signature = self.make_qml_signal_signature(n, iface_name, slotname, True) - out.write("connect(api_, SIGNAL(" + sig_signature + "), this, SLOT(" + slot_signature + "));\n") - out.write("LOG4CXX_TRACE(logger_, \"CONNECT SIGNALS: \" << __PRETTY_FUNCTION__ );\n") - out.write("}\n\n") - - for (request,response) in request_responses: - in_params = [ self.make_param_desc(x, iface_name) for x in request.findall('param') ] - out_params = [ self.make_param_desc(x, iface_name) for x in response.findall('param') ] - - out.write("bool fill{0}{1}Reply(QDBusMessage& message, const QVariantMap& map) {{\n".format(classname, request.get('name'))) - with CodeBlock(out) as out: - out.write("int retCode_out = 0;\n") - out.write("GetArgFromMap(map, \"__retCode\", retCode_out);\n") - out.write("QVariant retCode_arg = QVariant::fromValue(retCode_out);\n") - out.write("message << retCode_arg;\n") - out.write("QString userMessage_out;\n") - out.write("GetArgFromMap(map, \"__message\", userMessage_out);\n") - out.write("QVariant userMessage_arg = QVariant::fromValue(userMessage_out);\n") - out.write("message << userMessage_arg;\n") - for p in out_params: - param_name = p.name - param_type = self.qt_param_type(p) - out.write("%s %s_out;\n" % (param_type, p.name)) - out.write("if (!GetArgFromMap(map, \"{0}\", {0}_out)) {{ return false; }}\n".format(p.name)) - self.write_param_validation(p, p.name + "_out", "return false", out) - out.write("QVariant {0}_arg;\n".format(p.name)) - out.write("{0}_arg.setValue({0}_out);\n".format(p.name)) - out.write("message << {0}_arg;\n".format(p.name)) - out.write("LOG4CXX_DEBUG(logger_, \"Output arguments:\\n\" << QVariant(map));\n") - out.write("LOG4CXX_TRACE(logger_, \"REPLY ASYNC: \" << __PRETTY_FUNCTION__ );\n") - out.write("return true;\n") - out.write("}\n\n") - - out.write("{0} {{\n".format(self.make_method_signature(request, response, iface_name, True))) - with CodeBlock(out) as out: - out.write("LOG4CXX_TRACE(logger_, \"ENTER: \" << __PRETTY_FUNCTION__ );\n") - out.write("int ret = 0;\n") - return_statement = "return ret;\n" - out.write("QVariantMap in_arg;\n"); - out.write("QVariant out_arg_v;\n"); - for param in in_params: - self.write_param_validation(param, param.name + "_in", "RaiseDbusError(this, InvalidData); return ret", out) - out.write("PutArgToMap(in_arg, \"" + param.name + "\", " + param.name + "_in);\n") - out.write("LOG4CXX_DEBUG(logger_, \"Input arguments:\\n\" << in_arg);\n") - method_name = request.get('name')[:1].lower() + request.get('name')[1:] - - out.write("dbusController->message = &message;\n") - out.write("dbusController->fill = &fill{0}{1}Reply;\n".format(classname, request.get("name"))) - - out.write("""if (!QMetaObject::invokeMethod(api_, "{0}", Qt::{1}Connection, Q_RETURN_ARG(QVariant, out_arg_v), Q_ARG(QVariant, QVariant(in_arg)))) {{\n""".format(method_name, invoke_type_connection)) - with CodeBlock(out) as out: - out.write("RaiseDbusError(this, InvalidData);\n") - out.write("LOG4CXX_ERROR(logger_, \"Can't invoke method " + method_name +"\");\n ") - out.write("return ret;\n") - out.write("}\n") - - out.write("dbusController->message = NULL;\n") - out.write("dbusController->fill = NULL;\n") - out.write("if (message.isDelayedReply()) {\n") - with CodeBlock(out) as out: - out.write("return ret;\n") - out.write("}\n") - - out.write("QVariantMap out_arg;\n") - out.write("if (out_arg_v.type() == QVariant::Map) {\n") - with CodeBlock(out) as out: - out.write("out_arg = out_arg_v.toMap();\n") - out.write("};\n") - - out.write("int err;\n") - out.write("""if (GetArgFromMap(out_arg, "__errno", err)) { RaiseDbusError(this, err); return ret; }\n""") - - out.write("int async_uid;\n") - out.write("if (GetArgFromMap(out_arg, \"__async_uid\", async_uid)) {\n") - with CodeBlock(out) as out: - out.write("message.setDelayedReply(true);\n") - out.write("dbusController->addMessage(message, &fill%s%sReply, async_uid);\n" % (classname, request.get('name'))) - out.write("LOG4CXX_TRACE(logger_, \"EXIT ASYNC: \" << __PRETTY_FUNCTION__ );\n") - out.write("return ret;\n"); - out.write("}\n\n") - - for param in out_params: - out.write("if (!GetArgFromMap(out_arg, \"{0}\", {0}_out)) {{ RaiseDbusError(this, InvalidData); return ret; }}\n".format(param.name)) - self.write_param_validation(param, param.name + "_out", "RaiseDbusError(this, InvalidData); return ret", out) - - out.write("GetArgFromMap(out_arg, \"__retCode\", ret);\n") - out.write("GetArgFromMap(out_arg, \"__message\", userMessage_out);\n") - out.write("LOG4CXX_DEBUG(logger_, \"Output arguments:\\n\" << QVariant(out_arg));\n") - out.write("LOG4CXX_TRACE(logger_, \"EXIT: \" << __PRETTY_FUNCTION__ );\n") - out.write("return ret;\n") - out.write("}\n\n") - - for n in notifications: - slotname = n.get('name') + '_qml' - slot_signature = self.make_qml_signal_signature(n, iface_name, slotname, False, True) - out.write(slot_signature + " {\n") - params = n.findall('param') - out.write(" LOG4CXX_TRACE(logger_, \"EMIT SIGNAL: \" << __PRETTY_FUNCTION__ );\n") - out.write(" LOG4CXX_DEBUG(logger_, \"Arguments:\\n{\"") - for p in params[0:-1]: - param = self.make_param_desc(p, iface_name) - out.write(" << \" " + param.name + ":\" << " + param.name + " << \",\"") - for p in params[-1:]: # last param without comma in end line - p = params[-1] - param = self.make_param_desc(p, iface_name) - out.write(" << \" " + param.name + ":\" << " + param.name) - out.write(" << \" }\");\n") - for p in params: - param = self.make_param_desc(p, iface_name) - param_type = self.qt_param_type(param) - param_name = 'p_' + param.name - if param.mandatory: - if param.array or (param.type not in ['Integer', 'String', 'Float', 'Boolean'] and not param.enum): - out.write(' ' + param_type + ' ' + param_name + ";\n") - out.write(' if (!VariantToValue(' + param.name + ', ' + param_name + ")) {\n") - out.write(" LOG4CXX_ERROR(logger_, \"Can't convert variant to value\");\n") - out.write(" return;}\n") - else: - out.write(' ' + param_type + ' ' + param_name + ";\n") - out.write(' ' + param_name + '.presence = !' + param.name + ".isNull();\n") - out.write(' if (' + param_name + ".presence) {\n") - out.write(' if (!VariantToValue(' + param.name + ', ' + param_name + ".val)) {\n") - out.write(" LOG4CXX_ERROR(logger_, \"Can't convert variant to value\");\n") - out.write(" return;\n }\n") - out.write(" }\n") - out.write(' emit ' + n.get('name') + '(') - for i in range(len(params)): - param = self.make_param_desc(params[i], iface_name) - basic_type = (param.type in ['Integer', 'String', 'Float', 'Boolean']) or param.enum - if param.array or (not param.mandatory) or (not basic_type): - param_name = 'p_' + param.name - else: - param_name = param.name - out.write(param_name) - if i != len(params) - 1: out.write(', ') - out.write(");\n") - out.write("}\n\n") - - - def make_dbus_adaptor_declarations(self, out): - for interface_el in self.el_tree.findall('interface'): - notifications = self.find_notifications_by_provider(interface_el, "hmi") - request_responses = self.find_request_response_pairs_by_provider(interface_el, "hmi") - if len(notifications) > 0 or len(request_responses) > 0: - self.write_adaptor_declaration(interface_el, notifications, request_responses, out) - - - def make_dbus_adaptor_definitions(self, out): - for interface_el in self.el_tree.findall('interface'): - notifications = self.find_notifications_by_provider(interface_el, "hmi") - request_responses = self.find_request_response_pairs_by_provider(interface_el, "hmi") - if len(notifications) > 0 or len(request_responses) > 0: - self.write_adaptor_definition(interface_el, notifications, request_responses, out) - - - def make_dbus_register_metatypes_declaraion(self, out): - out.write("void RegisterDbusMetatypes();\n") - - - def make_dbus_register_metatypes_definition(self, out): - out.write("void RegisterDbusMetatypes() {\n") - for (iface, name) in self.structs: - struct_name = iface + '_' + name - out.write('qDBusRegisterMetaType<' + struct_name + ">();\n") - out.write('qDBusRegisterMetaType<OptionalArgument<' + struct_name + "> >();\n") - out.write('qDBusRegisterMetaType<QList<' + struct_name + "> >();\n") - out.write('qDBusRegisterMetaType<OptionalArgument<QList<' + struct_name + "> > >();\n") - out.write("}\n") - - - def make_api_adaptors_class(self, out): - global prefix_class_item - out.write("struct ApiAdaptors {\n") - interfaces = self.el_tree.findall('interface') - def filt(iface): - return self.find_notifications_by_provider(iface, "hmi") or self.find_request_response_pairs_by_provider(iface, "hmi") - interfaces = filter(filt, interfaces) - for interface_el in interfaces: - name = interface_el.get('name') + 'Adaptor' - out.write(" " + name + "* " + name + "_;\n") - out.write(" ApiAdaptors() :\n") - for i in range(len(interfaces)): - name = interfaces[i].get('name') + 'Adaptor' - out.write(" " + name + "_(NULL)") - if i <> len(interfaces) - 1: out.write(',') - out.write("\n") - out.write(" {}\n") - out.write(" void Init(QObject* p) {\n") - for interface_el in interfaces: - name = interface_el.get('name') + 'Adaptor' - out.write(" " + name + "_ = new " + name + "(p);\n") - out.write(" }\n") - out.write(" void SetApi(QObject* p) {\n") - for interface_el in interfaces: - name = interface_el.get('name') + 'Adaptor' - chname = interface_el.get('name') - out.write(" " + name + ("_->SetApi(p->findChild<Q%sItem*>(\"" % prefix_class_item) + chname + "\"));\n") - out.write(" }\n") - out.write(" void SetDBusController(DBusController* dc) {\n") - for interface_el in interfaces: - name = interface_el.get('name') + 'Adaptor' - chname = interface_el.get('name') - out.write(" " + name + "_->dbusController = dc;\n") - out.write(" }\n") - out.write("};\n\n") - - - -arg_parser = ArgumentParser(description="Generator of Qt to QDbus C++ part") -arg_parser.add_argument('--infile', required=True, help="full name of input file, e.g. applink/src/components/interfaces/QT_HMI_API.xml") -arg_parser.add_argument('--version', required=False, help="Qt version 4.8.5 (default) or 5.1.0") -arg_parser.add_argument('--outdir', required=True, help="path to directory where output files qml_dbus.cc, qml_dbus.h will be saved") -args = arg_parser.parse_args() - -if args.version == "4.8.5": - prefix_class_item = 'Declarative' - invoke_type_connection = 'Direct' -elif args.version == "5.1.0": - prefix_class_item = 'Quick' - invoke_type_connection = 'BlockingQueued' - -header_name = 'qml_dbus.h' -source_name = 'qml_dbus.cc' - -in_tree = ElementTree.parse(args.infile) -in_tree_root = in_tree.getroot() - -impl = Impl(in_tree_root, 'com.ford.sdl.hmi') - -header_out = open(args.outdir + '/' + header_name, "w") -source_out = open(args.outdir + '/' + source_name, "w") - -header_out.write("// Warning! This file is generated by '%s'. Edit at your own risk.\n" % argv[0]) -header_out.write("""/** - * @file qml_dbus.h - * @brief Generated QDbus adaptors header file - * - * This file is a part of HMI D-Bus layer. - */ -// Copyright (c) 2013, Ford Motor Company -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following -// disclaimer in the documentation and/or other materials provided with the -// distribution. -// -// Neither the name of the Ford Motor Company nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -""") -header_out.write("#ifndef SRC_COMPONENTS_DBUS_QML_DBUS_H_\n"); -header_out.write("#define SRC_COMPONENTS_DBUS_QML_DBUS_H_\n\n"); -header_out.write("#include <QtDBus/QDBusArgument>\n"); -header_out.write("#include <QtDBus/QDBusMessage>\n"); -header_out.write("#include <QtDBus/QDBusConnection>\n"); -header_out.write("#include <QtDBus/QDBusAbstractAdaptor>\n"); -header_out.write("#include <QtDBus/QDBusMetaType>\n"); -header_out.write("#include <Qt%s/Q%sItem>\n" % (prefix_class_item, prefix_class_item)); -header_out.write("#include \"qml_dbus_common.h\"\n\n"); -header_out.write("#include \"dbus_controller.h\"\n\n"); -impl.make_dbus_type_declarations(header_out) -impl.make_dbus_adaptor_declarations(header_out) -impl.make_dbus_register_metatypes_declaraion(header_out) -impl.make_api_adaptors_class(header_out) -impl.make_dbus_metatype_declarations(header_out) -header_out.write("#endif // #ifndef SRC_COMPONENTS_DBUS_QML_DBUS_H_\n"); - -source_out.write("// Warning! This file is generated by '%s'. Edit at your own risk.\n" % argv[0]) -source_out.write("""/** - * @file qml_dbus.cc - * @brief Generated QDbus adaptors source file - * - * This file is a part of HMI D-Bus layer. - */ -// Copyright (c) 2013, Ford Motor Company -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following -// disclaimer in the documentation and/or other materials provided with the -// distribution. -// -// Neither the name of the Ford Motor Company nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -""") -source_out.write("#include \"" + header_name + "\"\n\n"); -source_out.write("#include \"utils/logger.h\"\n") -source_out.write("#ifdef ENABLE_LOG\n") -source_out.write("extern log4cxx::LoggerPtr logger_;\n") -source_out.write("#endif // ENABLE_LOG\n\n") -impl.make_dbus_type_definitions(source_out) -impl.make_dbus_adaptor_definitions(source_out) -impl.make_dbus_register_metatypes_definition(source_out) diff --git a/src/components/dbus/codegen/make_qml_dbus_qml.py b/src/components/dbus/codegen/make_qml_dbus_qml.py deleted file mode 100755 index 8d057dcda1..0000000000 --- a/src/components/dbus/codegen/make_qml_dbus_qml.py +++ /dev/null @@ -1,217 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# @file make_qml_dbus_qml.py -# @brief Generator of QML to QDbus QML part -# -# This file is a part of HMI D-Bus layer. -# -# Copyright (c) 2013, Ford Motor Company -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with the -# distribution. -# -# Neither the name of the Ford Motor Company nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -from os import path -from os import makedirs -from sys import argv -from argparse import ArgumentParser -from xml.etree import ElementTree -from copy import copy -from ford_xml_parser import FordXmlParser - -namespace = 'dbus_qml' -qt_quick_version = '1.1' -type_variant_name = 'variant' - -class Impl(FordXmlParser): - def write_function(self, ifacename, request, response, out): - name = request.get('name') - name = name[:1].lower() + name[1:] - out.write(" function " + name + "(params) {\n") - out.write(""" console.debug("{0}Proxy::{1}")\n""".format(ifacename, name)) - out.write(" try {\n") - out.write(" if(\"{0}\" in sdl{1})\n".format(name, ifacename)) - out.write(" return sdl{0}.{1}(" .format(ifacename, name)) - params = request.findall('param') - for i in range(len(params)): - out.write('params.' + params[i].get('name')) - if i <> len(params) - 1: - out.write(', ') - out.write(")\n") - out.write(" else\n") - out.write(""" return { "__errno": Common.Result.UNSUPPORTED_REQUEST }\n""") - out.write(" } catch(err) {\n") - out.write(""" return { "__errno": err }\n""") - out.write(" }\n") - out.write(" }\n\n") - - - def write_signal_param(self, param, out): - if param.array or param.struct or not param.mandatory: typ = type_variant_name - elif param.type == 'Integer' or param.enum: typ = 'int' - elif param.type == 'String': typ = 'string' - elif param.type == 'Boolean': typ = 'bool' - elif param.type == 'Float': typ = 'double' - else: typ = type_variant_name - out.write(typ + ' ' + param.name) - - - def write_signal(self, ifacename, notification, out): - name = notification.get('name') - name = name[:1].lower() + name[1:] - out.write(" signal " + name + "(") - params = notification.findall('param') - for i in range(len(params)): - self.write_signal_param(self.make_param_desc(params[i], ifacename), out) - if i <> len(params) - 1: - out.write(', ') - out.write(")\n") - name = notification.get('name') - out.write(""" on{1}: console.debug("emitted {0}:{1}")\n""".format(ifacename, name)) - - - def write_qml(self, iface, out): - global qt_quick_version - name = iface.get('name') - out.write("import QtQuick %s\n" % qt_quick_version) - out.write("""import "Common.js" as Common\n""") - out.write("import \"..\"\n\n") - out.write("Item {\n") - out.write(" " + name + " {\n") - out.write(" id: sdl" + name + "\n") - out.write(" }\n") - - notifications = impl.find_notifications_by_provider(interface_el, "hmi") - request_responses = impl.find_request_response_pairs_by_provider(interface_el, "hmi") - for request, response in request_responses: - self.write_function(name, request, response, out) - for n in notifications: - self.write_signal(name, n, out) - out.write("}\n") - - - def write_js_enum(self, enum, out): - out.write("var " + enum.get('name') + " = {\n") - lastval = -1 - elements = enum.findall('element') - for i in range(len(elements)): - element = elements[i] - value = element.get('value') - if value is None: - value = lastval + 1 - else: - value = int(value) - lastval = value - name = element.get('internal_name') - if name is None: - name = element.get('name') - out.write(" " + name + ': ' + str(value)) - if len(elements) - 1 != i: out.write(',') - out.write("\n") - out.write("}\n\n") - - -def write_header(out): - out.write("// Warning! This file is generated by '%s'. Edit at your own risk.\n" % argv[0]) - out.write("""/** - * Copyright (c) 2013, Ford Motor Company - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the Ford Motor Company nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -""") - -arg_parser = ArgumentParser(description="Generator of Qt to QDbus QML part") -arg_parser.add_argument('--infile', required=True, help="full name of input file, e.g. applink/src/components/interfaces/QT_HMI_API.xml") -arg_parser.add_argument('--version', required=False, help="Qt version 4.8.5 (default) or 5.1.0") -arg_parser.add_argument('--outdir', required=True, help="path to directory where output files with pattern name <intarface name>Proxy.qml will be saved, e.g. BasicCommunicationProxy.qml, ButtonsProxy.qml VRProxy.qml") -args = arg_parser.parse_args() - -if args.version == "4.8.5": - qt_quick_version = "1.1" - type_variant_name = "variant" -elif args.version == "5.1.0": - qt_quick_version = "2.0" - type_variant_name = "var" - -if not path.isdir(args.outdir): - makedirs(args.outdir) - -in_tree = ElementTree.parse(args.infile) -in_tree_root = in_tree.getroot() - -impl = Impl(in_tree_root) - -for interface_el in in_tree_root.findall('interface'): - notifications = impl.find_notifications_by_provider(interface_el, "hmi") - request_responses = impl.find_request_response_pairs_by_provider(interface_el, "hmi") - if notifications or request_responses: - filename = interface_el.get('name')+'Proxy.qml' - outfile = open(args.outdir + '/' + filename, 'w') - write_header(outfile) - impl.write_qml(interface_el, outfile) - -enum_files = dict() -for (iface, name), enum in impl.enums.items(): - if iface in enum_files: - outfile = enum_files[iface] - else: - filename = iface+'.js' - outfile = open(args.outdir + '/' + filename, 'w') - write_header(outfile) - outfile.write(".pragma library\n") - enum_files[iface] = outfile - impl.write_js_enum(enum, outfile) - - diff --git a/src/components/dbus/codegen/make_qml_requests_cpp.py b/src/components/dbus/codegen/make_qml_requests_cpp.py deleted file mode 100644 index 6674b8f5e2..0000000000 --- a/src/components/dbus/codegen/make_qml_requests_cpp.py +++ /dev/null @@ -1,253 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# @file make_qml_dbus_cpp.py -# @brief Generator of QML to QDbus C++ part -# -# This file is a part of HMI D-Bus layer. -# -# Copyright (c) 2014, Ford Motor Company -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with the -# distribution. -# -# Neither the name of the Ford Motor Company nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -from argparse import ArgumentParser -import os.path -from sys import argv -from xml.etree import ElementTree -from copy import copy -from ford_xml_parser import FordXmlParser, ParamDesc -from code_formatter import CodeBlock - -prefix_class_item = 'Declarative' -invoke_type_connection = 'Direct' - -def defaultValue(param): - if param.type == "Integer": - return "0" - elif param.type == "Float": - return "0.0" - elif param.type == "Boolean": - return "false" - elif param.enum: - return "0" - -class Impl(FordXmlParser): - - - def args_for_function_definition(self, params, out): - if len(params) == 0: - out.write('QJSValue hmi_callback') - return - for param in params: - out.write('QVariant ' + param.get('name') + ', ') - out.write('QJSValue hmi_callback') - - - def make_requests_for_header(self, out): - for interface_el in self.el_tree.findall('interface'): - request_responses = self.find_request_response_pairs_by_provider(interface_el, "sdl") - for (request, response) in request_responses: - all_params = list() - for param_el in request.findall('param'): - all_params.append(param_el) - with CodeBlock(out) as output: - output.write("Q_INVOLABKE void " + interface_el.get('name') + "_" +request.get('name') + "(") - impl.args_for_function_definition(all_params, out) - output.write(");\n") - - - def make_header_file(self, out): - out.write("class RequestToSDL : public QObject\n") - out.write("{\n") - out.write(" public:\n") - with CodeBlock(out) as output: - output.write("explicit RequestToSDL(QObject *parent = 0);\n") - output.write("~RequestToSDL();\n") - impl.make_requests_for_header(out) - out.write(" private:\n") - with CodeBlock(out) as output: - for interface_el in self.el_tree.findall('interface'): - output.write('QDBusInterface *' + interface_el.get('name') + ';\n') - out.write("};\n") - - - def make_requests_for_source(self, out): - for interface_el in self.el_tree.findall('interface'): - request_responses = self.find_request_response_pairs_by_provider(interface_el, "sdl") - for (request, response) in request_responses: - out.write('void RequestToSDL::' + request.get('name') + '(QString name, ') - for param_el in request.findall('param'): - out.write('QVariant ' + param_el.get('name') + ', ') - out.write('QJSValue hmi_callback) {\n') - with CodeBlock(out) as output: - output.write('QList<QVariant> args;\n') - for param_el in request.findall('param'): - output.write('args << ' + param_el.get('name') + ';\n') - output.write('new ' + interface_el.get('name') + '_' + request.get('name') + '(' + interface_el.get('name') + ', name, args, hmi_callback);\n}\n') - - - - def make_source_file(self, out): - out.write('#include "request_to_sdl.h"\n') - out.write('\n') - out.write('RequestToSDL::RequestToSDL(QObject *parent) {\n') - with CodeBlock(out) as output: - output.write('QDBusConnection bus = QDBusConnection::sessionBus();\n') - for interface_el in self.el_tree.findall('interface'): - iface_name = interface_el.get('name') - output.write(iface_name + ' = new QDBusInterface("com.ford.sdl.core", "/", "com.ford.sdl.core.' + iface_name + '", bus, this);\n') - out.write('}\n\n') - out.write('RequestToSDL::~RequestToSDL() {\n') - with CodeBlock(out) as output: - for interface_el in self.el_tree.findall('interface'): - iface_name = interface_el.get('name') - output.write(iface_name + '->deleteLater();\n') - output.write('this->deleteLater();\n') - out.write('}\n\n') - impl.make_requests_for_source(out) - - - - - -arg_parser = ArgumentParser(description="Generator of Qt to QDbus C++ part") -arg_parser.add_argument('--infile', required=True, help="full name of input file, e.g. applink/src/components/interfaces/QT_HMI_API.xml") -arg_parser.add_argument('--version', required=False, help="Qt version 4.8.5 (default) or 5.1.0") -arg_parser.add_argument('--outdir', required=True, help="path to directory where output files request_to_sdl.h, request_to_sdl.cc will be saved") -args = arg_parser.parse_args() - -if args.version == "4.8.5": - prefix_class_item = 'Declarative' - invoke_type_connection = 'Direct' -elif args.version == "5.1.0": - prefix_class_item = 'Quick' - invoke_type_connection = 'BlockingQueued' - -header_name = 'request_to_sdl.h' -source_name = 'request_to_sdl.cc' - -in_tree = ElementTree.parse(args.infile) -in_tree_root = in_tree.getroot() - -impl = Impl(in_tree_root, 'com.ford.sdl.hmi') - -header_out = open(args.outdir + '/' + header_name, "w") -source_out = open(args.outdir + '/' + source_name, "w") - -header_out.write("// Warning! This file is generated by '%s'. Edit at your own risk.\n" % argv[0]) -header_out.write("""/** - * @file request_to_sdl.h - * @brief Generated class that process requests from qtHMI - * - * This file is a part of HMI D-Bus layer. - */ -// Copyright (c) 2013, Ford Motor Company -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following -// disclaimer in the documentation and/or other materials provided with the -// distribution. -// -// Neither the name of the Ford Motor Company nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -""") -header_out.write("#ifndef SRC_COMPONENTS_QTHMI_QMLMODELQT5_REQUESTTOSDL_\n"); -header_out.write("#define SRC_COMPONENTS_QTHMI_QMLMODELQT5_REQUESTTOSDL_\n\n"); -header_out.write("#include <QDBusConnection>\n"); -header_out.write("#include <QJSValue>\n"); -header_out.write("#include <QObject>\n"); -header_out.write("#include <QDBusInterface>\n"); -header_out.write('#include "hmi_requests.h"\n'); - -impl.make_header_file(header_out) - -header_out.write("#endif SRC_COMPONENTS_QTHMI_QMLMODELQT5_REQUESTTOSDL_\n"); - - -source_out.write("// Warning! This file is generated by '%s'. Edit at your own risk.\n" % argv[0]) -source_out.write("""/** - * @file request_to_sdl.cc - * @brief Generated class that process requests from qtHMI - * - * This file is a part of HMI D-Bus layer. - */ -// Copyright (c) 2014, Ford Motor Company -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following -// disclaimer in the documentation and/or other materials provided with the -// distribution. -// -// Neither the name of the Ford Motor Company nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. - -""") - -impl.make_source_file(source_out) diff --git a/src/components/dbus/codegen/make_request_to_sdl.py b/src/components/dbus/codegen/make_request_to_sdl.py deleted file mode 100755 index c8940f3eb7..0000000000 --- a/src/components/dbus/codegen/make_request_to_sdl.py +++ /dev/null @@ -1,335 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# @file make_qml_dbus_cpp.py -# @brief Generator of QML to QDbus C++ part -# -# This file is a part of HMI D-Bus layer. -# -# Copyright (c) 2014, Ford Motor Company -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following -# disclaimer in the documentation and/or other materials provided with the -# distribution. -# -# Neither the name of the Ford Motor Company nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -from argparse import ArgumentParser -import os.path -from sys import argv -from xml.etree import ElementTree -from copy import copy -from ford_xml_parser import FordXmlParser, ParamDesc -from code_formatter import CodeBlock - -class Impl(FordXmlParser): - - def args_for_function_definition(self, params, iface_name, out): - for param_el in params: - param = self.make_param_desc(param_el, iface_name) - out.write('QVariant %s,' % (param.name)) - out.write('Q%sValue hmi_callback' % prefix_class_item) - - def make_requests_for_header(self, out): - for interface_el in self.el_tree.findall('interface'): - request_responses = self.find_request_response_pairs_by_provider(interface_el, "sdl") - for (request, response) in request_responses: - all_params = list() - for param_el in request.findall('param'): - all_params.append(param_el) - with CodeBlock(out) as output: - output.write("Q_INVOKABLE bool %s_%s(" % (interface_el.get('name'), request.get('name'))) - impl.args_for_function_definition(all_params, interface_el.get('name'), out) - output.write(");\n") - - - def make_header_file(self, out): - out.write("class QDBusInterface;\n") - out.write("class RequestToSDL : public QObject\n") - out.write("{\n") - out.write(' Q_OBJECT\n') - out.write(" public:\n") - with CodeBlock(out) as output: - output.write("explicit RequestToSDL(QObject *parent = 0);\n") - output.write("~RequestToSDL();\n") - impl.make_requests_for_header(out) - out.write(" private:\n") - with CodeBlock(out) as output: - for interface_el in self.el_tree.findall('interface'): - output.write('QDBusInterface *%s;\n' % interface_el.get('name')) - out.write("};\n") - - - def qt_param_type(self, param): - if not param.mandatory: - param_copy = copy(param) - param_copy.mandatory = True - return "OptionalArgument< " + self.qt_param_type(param_copy) + " >" - if param.array: - param_copy = copy(param) - param_copy.array = False - if param.type == 'String': - return "QStringList" - return "QList< " + self.qt_param_type(param_copy) + " >" - if param.type == 'Integer' or param.enum: - return 'int' - elif param.type == 'String': - return 'QString' - elif param.type == 'Boolean': - return 'bool' - elif param.type == 'Float': - return 'double' - elif param.struct: - return "_".join(param.fulltype) - else: - raise RuntimeError('Unknown type: ' + param.type) - - - def make_requests_for_source(self, out): - for interface_el in self.el_tree.findall('interface'): - request_responses = self.find_request_response_pairs_by_provider(interface_el, "sdl") - for (request, response) in request_responses: - request_name = request.get('name') - iface_name = interface_el.get('name') - request_full_name = iface_name + '_' + request_name - out.write('bool RequestToSDL::' + request_full_name + '(') - for param_el in request.findall('param'): - out.write('QVariant %s, ' % (param_el.get('name'))) - out.write('Q%sValue hmi_callback) {\n' % prefix_class_item) - with CodeBlock(out) as output: - output.write('LOG4CXX_TRACE(logger_, "ENTER");\n') - output.write('QList<QVariant> args;\n') - for param_el in request.findall('param'): - param = self.make_param_desc(param_el, iface_name) - output.write('%s %s;\n' % (impl.qt_param_type(param), param.name + "_tmp")) - output.write('if (VariantToValue(%s, %s)) {\n' % (param.name, param.name + '_tmp')) - with CodeBlock(output) as out: - self.write_param_validation(param, param.name + "_tmp", - "\nLOG4CXX_ERROR(logger_, \"%s in %s out of bounds\");\nreturn false" % (param.name, request_full_name), - out) - out.write('args << QVariant::fromValue(%s);\n' % (param.name + '_tmp')) - output.write('} else {\n') - with CodeBlock(output) as out: - out.write('LOG4CXX_ERROR(logger_, "%s in %s is NOT valid");\n' % (param.name, request_full_name)) - out.write('return false;\n') - out.write('}\n') - output.write('new requests::' + request_full_name + '(hmi_callback, ' + interface_el.get('name') + ' , args, ' - + '"' + request_name + '");\n') - output.write('LOG4CXX_TRACE(logger_, "EXIT");\n') - output.write('return true;\n') - out.write('}\n\n') - - - def write_param_validation(self, param, param_name, fail_statement, out, level=0): - if not param.mandatory and (param.restricted or param.restrictedArray or (param.struct and any(map(lambda x: x.restricted, self.structs[param.fulltype])))): - out.write("if (%s.presence) {\n" % param_name) - param_copy = copy(param) - param_copy.mandatory = True - with CodeBlock(out) as out: - self.write_param_validation(param_copy, param_name + ".val", fail_statement, out, level+1) - out.write("}\n") - elif param.array: - if param.minSize > 0: - out.write("if ({0}.count() < {1}) {{".format(param_name, param.minSize)) - with CodeBlock(out) as out: - out.write("{0};\n".format(fail_statement)) - out.write("}\n") - if param.maxSize != None: - out.write("if ({0}.count() > {1}) {{".format(param_name, param.maxSize)) - with CodeBlock(out) as out: - out.write("{0};\n".format(fail_statement)) - out.write("}\n") - if param.restricted: - out.write('for ({0}::const_iterator it_{2} = {1}.begin(); it_{2} != {1}.end(); ++it_{2}) {{\n'.format(self.qt_param_type(param), param_name, level)) - with CodeBlock(out) as out: - param_copy = copy(param) - param_copy.array = False - self.write_param_validation(param_copy, "(*it_{0})".format(level), fail_statement, out, level+1) - out.write("}\n") - elif param.struct: - for p in self.structs[param.fulltype]: - self.write_param_validation(p, "{0}.{1}".format(param_name, p.name), fail_statement, out, level+1) - elif param.type == "Integer" or param.type == "Float": - conditions = [] - if (param.minValue != None): - conditions.append("(%s < %s)" % (param_name, param.minValue)) - if (param.maxValue != None): - conditions.append("(%s > %s)" % (param_name, param.maxValue)) - if conditions: - out.write('if (%s) {' % ' || '.join(conditions)) - with CodeBlock(out) as out: - out.write('%s;\n' % fail_statement) - out.write("}\n") - elif param.type == "String": - conditions = [] - if (param.minLength > 0): - conditions.append("(%s.size() < %s)" % (param_name, param.minLength)) - if (param.maxLength > 0): - conditions.append("(%s.size() > %s)" % (param_name, param.maxLength)) - if conditions: - out.write('if (%s) {' % ' || '.join(conditions)) - with CodeBlock(out) as out: - out.write('%s;\n' % (fail_statement)) - out.write("}\n") - - def make_source_file(self, out): - out.write('RequestToSDL::RequestToSDL(QObject *parent) {\n') - with CodeBlock(out) as output: - output.write('QDBusConnection bus = QDBusConnection::sessionBus();\n') - for interface_el in self.el_tree.findall('interface'): - iface_name = interface_el.get('name') - output.write(iface_name + ' = new QDBusInterface("com.ford.sdl.core", "/", "com.ford.sdl.core.' + iface_name + '", bus, this);\n') - out.write('}\n\n') - out.write('RequestToSDL::~RequestToSDL() {\n') - with CodeBlock(out) as output: - for interface_el in self.el_tree.findall('interface'): - iface_name = interface_el.get('name') - output.write(iface_name + '->deleteLater();\n') - output.write('this->deleteLater();\n') - out.write('}\n\n') - impl.make_requests_for_source(out) - -arg_parser = ArgumentParser(description="Generator of Qt to QDbus C++ part") -arg_parser.add_argument('--infile', required=True, help="full name of input file, e.g. applink/src/components/interfaces/QT_HMI_API.xml") -arg_parser.add_argument('--version', required=False, help="Qt version 4.8.5 (default) or 5.1.0") -arg_parser.add_argument('--outdir', required=True, help="path to directory where output files request_to_sdl.h, request_to_sdl.cc will be saved") -args = arg_parser.parse_args() - - -if args.version == "4.8.5": - prefix_class_item = 'Script' - invoke_type_connection = 'Direct' -elif args.version == "5.1.0": - prefix_class_item = 'JS' - invoke_type_connection = 'BlockingQueued' -else: - prefix_class_item = 'JS' - invoke_type_connection = 'BlockingQueued' - -header_name = 'request_to_sdl.h' -source_name = 'request_to_sdl.cc' - -in_tree = ElementTree.parse(args.infile) -in_tree_root = in_tree.getroot() - -impl = Impl(in_tree_root, 'com.ford.sdl.hmi') - -header_out = open(args.outdir + '/' + header_name, "w") -source_out = open(args.outdir + '/' + source_name, "w") - -header_out.write("// Warning! This file is generated by '%s'. Edit at your own risk.\n" % argv[0]) -header_out.write(""" -/* - Copyright (c) 2014, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ -""") -header_out.write("#ifndef SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_REQUEST_TO_SDL_H_\n") -header_out.write("#define SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_REQUEST_TO_SDL_H_\n\n") - -header_out.write("#include <QtCore/QObject>\n") -header_out.write("#include <QtCore/QVariant>\n") -header_out.write("#include <QtCore/QStringList>\n\n") -header_out.write('#include "qml_dbus.h"\n\n') -if args.version == "4.8.5": - header_out.write("#include <QtScript/QScriptValue>\n") -elif args.version == "5.1.0": - header_out.write("#include <QtQml/QJSValue>\n") - -impl.make_header_file(header_out) -header_out.write("#endif // SRC_COMPONENTS_QT_HMI_QML_PLUGINS_DBUS_ADAPTER_REQUEST_TO_SDL_H_") - - -source_out.write("// Warning! This file is generated by '%s'. Edit at your own risk.\n" % argv[0]) -source_out.write(""" -/* - Copyright (c) 2014, Ford Motor Company - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following - disclaimer in the documentation and/or other materials provided with the - distribution. - - Neither the name of the Ford Motor Company nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 'A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -""") - -source_out.write('#include "request_to_sdl.h"\n') -source_out.write("#include <QtDBus/QDBusConnection>\n") -source_out.write("#include <QtDBus/QDBusInterface>\n") -source_out.write('#include "hmi_requests.h"\n') -source_out.write('#include "utils/logger.h"\n\n') -source_out.write('CREATE_LOGGERPTR_GLOBAL(logger_, "DBusPlugin")\n\n') - -impl.make_source_file(source_out) |