Esempio n. 1
0
    def __init__(self, el, externals, custom_lists):
        self.el = el
        name = get_by_path(el, '@name')
        array_name = get_by_path(el, '@array-name')
        array_depth = get_by_path(el, '@array-depth')
        if array_depth:
            array_depth = int(array_depth)
        else:
            array_depth = None
        self.binding = binding_from_decl(name, array_name, array_depth)
        self.deps = []

        for member in get_by_path(el, 'member'):
            sig = member.getAttribute('type')
            tptype = member.getAttributeNS(NS_TP, 'type')

            if (sig, tptype) in externals:
                continue

            if tptype.endswith('[]'):
                tptype = tptype[:-2]

            binding = binding_from_usage(sig, tptype, custom_lists)

            if binding.custom_type:
                self.deps.append(binding.val)

        self.revdeps = []
Esempio n. 2
0
    def __init__(self, el, externals, custom_lists):
        self.el = el
        name = get_by_path(el, '@name')
        array_name = get_by_path(el, '@array-name')
        array_depth = get_by_path(el, '@array-depth')
        if array_depth:
            array_depth = int(array_depth)
        else:
            array_depth = None
        self.binding = binding_from_decl(name, array_name, array_depth)
        self.deps = []

        for member in get_by_path(el, 'member'):
            sig = member.getAttribute('type')
            tptype = member.getAttributeNS(NS_TP, 'type')

            if (sig, tptype) in externals:
                continue

            if tptype.endswith('[]'):
                tptype = tptype[:-2]

            binding = binding_from_usage(sig, tptype, custom_lists)

            if binding.custom_type:
                self.deps.append(binding.val)

        self.revdeps = []
    def do_prop_introspection(self, props):
        for prop in props:
            if prop.namespaceURI:
                continue

            name = prop.getAttribute('name')
            access = prop.getAttribute('access')
            sig = prop.getAttribute('type')
            tptype = prop.getAttributeNS(NS_TP, 'type')
            binding = binding_from_usage(sig, tptype, self.custom_lists,
                                         (sig, tptype) in self.externals,
                                         self.typesnamespace)

            if not binding.custom_type:
                self.h("""\
"    <property access=\\"%(access)s\\" type=\\"%(sig)s\\" name=\\"%(name)s\\"/>\\n"
""" % {
                    'access': access,
                    'sig': sig,
                    'name': name,
                })
            else:
                self.h(
                    """\
"    <property access=\\"%(access)s\\" type=\\"%(sig)s\\" name=\\"%(name)s\\">\\n"
"      <annotation value=\\"%(type)s\\" name=\\"com.trolltech.QtDBus.QtTypeName\\"/>\\n"
"    </property>\\n"
""" % {
                        'access': access,
                        'sig': sig,
                        'name': name,
                        'type': binding.val,
                    })
Esempio n. 4
0
    def do_prop_introspection(self, props):
        for prop in props:
            if prop.namespaceURI:
                continue

            name = prop.getAttribute('name')
            access = prop.getAttribute('access')
            sig = prop.getAttribute('type')
            tptype = prop.getAttributeNS(NS_TP, 'type')
            binding = binding_from_usage(sig, tptype, self.custom_lists, (sig, tptype) in self.externals, self.typesnamespace)

            if not binding.custom_type:
                self.h("""\
"    <property access=\\"%(access)s\\" type=\\"%(sig)s\\" name=\\"%(name)s\\"/>\\n"
""" % {'access': access,
       'sig': sig,
       'name': name,
       })
            else:
                self.h("""\
"    <property access=\\"%(access)s\\" type=\\"%(sig)s\\" name=\\"%(name)s\\">\\n"
"      <annotation value=\\"%(type)s\\" name=\\"com.trolltech.QtDBus.QtTypeName\\"/>\\n"
"    </property>\\n"
""" % {'access': access,
       'sig': sig,
       'name': name,
       'type': binding.val,
       })
Esempio n. 5
0
    def do_prop(self, prop):
        name = prop.getAttribute('name')
        access = prop.getAttribute('access')
        gettername = name
        settername = None
        docstring = format_docstring(prop, self.refs, '     * ').replace('*/', '&#42;&#47;')

        sig = prop.getAttribute('type')
        tptype = prop.getAttributeNS(NS_TP, 'type')
        binding = binding_from_usage(sig, tptype, self.custom_lists, (sig, tptype) in self.externals, self.typesnamespace)

        if 'write' in access:
            settername = 'set' + name

        if 'read' in access:
            self.h("""
    /**
     * Asynchronous getter for the remote object property \\c %(name)s of type \\c %(val)s.
     *
%(docstring)s\
     *
     * \\return A pending variant which will emit finished when the property has been
     *          retrieved.
     */
    inline Tp::PendingVariant *%(gettername)s() const
    {
        return internalRequestProperty(QLatin1String("%(name)s"));
    }
""" % {'name' : name,
       'docstring' : docstring,
       'val' : binding.val,
       'gettername' : 'requestProperty' + name})

        if 'write' in access:
            self.h("""
    /**
     * Asynchronous setter for the remote object property \\c %(name)s of type \\c %(type)s.
     *
%(docstring)s\
     *
     * \\return A pending operation which will emit finished when the property has been
     *          set.
     */
    inline Tp::PendingOperation *%(settername)s(%(type)s newValue)
    {
        return internalSetProperty(QLatin1String("%(name)s"), QVariant::fromValue(newValue));
    }
""" % {'name' : name,
       'docstring' : docstring,
       'type' : binding.val,
       'name' : name,
       'settername' : 'setProperty' + name})
Esempio n. 6
0
    def gather_required(self):
        members = self.spec.getElementsByTagNameNS(NS_TP, 'member')
        args = self.spec.getElementsByTagName('arg')
        props = self.spec.getElementsByTagName('property')
        tp_props = self.spec.getElementsByTagNameNS(NS_TP, 'property')

        for requirer in members + args + props + tp_props:
            sig = requirer.getAttribute('type')
            tptype = requirer.getAttributeNS(NS_TP, 'type')
            external = (sig, tptype) in self.externals
            binding = binding_from_usage(sig, tptype, self.custom_lists, external)

            if binding.custom_type and binding.val not in self.required_custom:
                self.required_custom.append(binding.val)

            if not binding.custom_type and binding.array_of and (binding.val, binding.array_of) not in self.required_arrays:
                self.required_arrays.append((binding.val, binding.array_of))
Esempio n. 7
0
    def gather_required(self):
        members = self.spec.getElementsByTagNameNS(NS_TP, 'member')
        args = self.spec.getElementsByTagName('arg')
        props = self.spec.getElementsByTagName('property')
        tp_props = self.spec.getElementsByTagNameNS(NS_TP, 'property')

        for requirer in members + args + props + tp_props:
            sig = requirer.getAttribute('type')
            tptype = requirer.getAttributeNS(NS_TP, 'type')
            external = (sig, tptype) in self.externals
            binding = binding_from_usage(sig, tptype, self.custom_lists, external)

            if binding.custom_type and binding.val not in self.required_custom:
                self.required_custom.append(binding.val)

            if not binding.custom_type and binding.array_of and (binding.val, binding.array_of) not in self.required_arrays:
                self.required_arrays.append((binding.val, binding.array_of))
Esempio n. 8
0
    def do_qprop(self, prop):
        name = prop.getAttribute('name')
        access = prop.getAttribute('access')
        gettername = name
        settername = None
        if 'write' in access:
            settername = 'Set' + name

        sig = prop.getAttribute('type')
        tptype = prop.getAttributeNS(NS_TP, 'type')
        binding = binding_from_usage(sig, tptype, self.custom_lists, (sig, tptype) in self.externals, self.typesnamespace)

        self.h("""\
    Q_PROPERTY(%(type)s %(name)s %(getter)s %(setter)s)
""" % {'type': binding.val,
       'name': name,
       'getter': 'READ ' + gettername if ('read' in access) else '',
       'setter': 'WRITE ' + settername if ('write' in access) else '',
       })
Esempio n. 9
0
    def do_qprop(self, prop):
        name = prop.getAttribute('name')
        access = prop.getAttribute('access')
        gettername = name
        settername = None
        if 'write' in access:
            settername = 'Set' + name

        sig = prop.getAttribute('type')
        tptype = prop.getAttributeNS(NS_TP, 'type')
        binding = binding_from_usage(sig, tptype, self.custom_lists, (sig, tptype) in self.externals, self.typesnamespace)

        self.h("""\
    Q_PROPERTY(%(type)s %(name)s %(getter)s %(setter)s)
""" % {'type': binding.val,
       'name': name,
       'getter': 'READ ' + gettername if ('read' in access) else '',
       'setter': 'WRITE ' + settername if ('write' in access) else '',
       })
Esempio n. 10
0
    def do_prop(self, ifacename, prop):
        name = prop.getAttribute('name')
        adaptee_name = to_lower_camel_case(
            prop.getAttribute('tp:name-for-bindings'))
        access = prop.getAttribute('access')
        gettername = name
        settername = None
        if 'write' in access:
            settername = 'Set' + name
        docstring = format_docstring(prop, self.refs,
                                     '     * ').replace('*/', '&#42;&#47;')

        sig = prop.getAttribute('type')
        tptype = prop.getAttributeNS(NS_TP, 'type')
        binding = binding_from_usage(sig, tptype, self.custom_lists,
                                     (sig, tptype) in self.externals,
                                     self.typesnamespace)

        if 'read' in access:
            self.h(
                """\
    /**
     * Return the value of the exported D-Bus object property \\c %(name)s of type \\c %(type)s.
     *
     * Adaptees should export this property as a Qt property named
     * '%(adaptee_name)s' with type %(type)s.
     *
%(docstring)s\
     *
     * \\return The value of exported property \\c %(name)s.
     */
    %(type)s %(gettername)s() const;
""" % {
                    'name': name,
                    'adaptee_name': adaptee_name,
                    'docstring': docstring,
                    'type': binding.val,
                    'gettername': gettername,
                })

            self.b(
                """
%(type)s %(ifacename)s::%(gettername)s() const
{
    return qvariant_cast< %(type)s >(adaptee()->property("%(adaptee_name)s"));
}
""" % {
                    'type': binding.val,
                    'ifacename': ifacename,
                    'gettername': gettername,
                    'adaptee_name': adaptee_name,
                })

        if 'write' in access:
            self.h(
                """\
    /**
     * Set the value of the exported D-Bus object property \\c %(name)s of type \\c %(type)s.
     *
     * Adaptees should export this property as a writable Qt property named
     * '%(adaptee_name)s' with type %(type)s.
     *
%(docstring)s\
     */
    void %(settername)s(const %(type)s &newValue);
""" % {
                    'name': name,
                    'adaptee_name': adaptee_name,
                    'docstring': docstring,
                    'settername': settername,
                    'type': binding.val,
                })

            self.b(
                """
void %(ifacename)s::%(settername)s(const %(type)s &newValue)
{
    adaptee()->setProperty("%(adaptee_name)s", qVariantFromValue(newValue));
}
""" % {
                    'ifacename': ifacename,
                    'settername': settername,
                    'type': binding.val,
                    'adaptee_name': adaptee_name,
                })
Esempio n. 11
0
    def do_prop(self, prop):
        name = prop.getAttribute('name')
        access = prop.getAttribute('access')
        gettername = name
        settername = None
        docstring = format_docstring(prop, self.refs,
                                     '     * ').replace('*/', '&#42;&#47;')

        sig = prop.getAttribute('type')
        tptype = prop.getAttributeNS(NS_TP, 'type')
        binding = binding_from_usage(sig, tptype, self.custom_lists,
                                     (sig, tptype) in self.externals,
                                     self.typesnamespace)

        if 'write' in access:
            settername = 'set' + name

        if 'read' in access:
            self.h(
                """
    /**
     * Asynchronous getter for the remote object property \\c %(name)s of type \\c %(val)s.
     *
%(docstring)s\
     *
     * \\return A pending variant which will emit finished when the property has been
     *          retrieved.
     */
    inline Tp::PendingVariant *%(gettername)s() const
    {
        return internalRequestProperty(QLatin1String("%(name)s"));
    }
""" % {
                    'name': name,
                    'docstring': docstring,
                    'val': binding.val,
                    'gettername': 'requestProperty' + name
                })

        if 'write' in access:
            self.h(
                """
    /**
     * Asynchronous setter for the remote object property \\c %(name)s of type \\c %(type)s.
     *
%(docstring)s\
     *
     * \\return A pending operation which will emit finished when the property has been
     *          set.
     */
    inline Tp::PendingOperation *%(settername)s(%(type)s newValue)
    {
        return internalSetProperty(QLatin1String("%(name)s"), QVariant::fromValue(newValue));
    }
""" % {
                    'name': name,
                    'docstring': docstring,
                    'type': binding.val,
                    'name': name,
                    'settername': 'setProperty' + name
                })
Esempio n. 12
0
    def do_prop(self, ifacename, prop):
        name = prop.getAttribute('name')
        adaptee_name = to_lower_camel_case(prop.getAttribute('tp:name-for-bindings'))
        access = prop.getAttribute('access')
        gettername = name
        settername = None
        if 'write' in access:
            settername = 'Set' + name
        docstring = format_docstring(prop, self.refs, '     * ').replace('*/', '&#42;&#47;')

        sig = prop.getAttribute('type')
        tptype = prop.getAttributeNS(NS_TP, 'type')
        binding = binding_from_usage(sig, tptype, self.custom_lists, (sig, tptype) in self.externals, self.typesnamespace)

        if 'read' in access:
            self.h("""\
    /**
     * Return the value of the exported D-Bus object property \\c %(name)s of type \\c %(type)s.
     *
     * Adaptees should export this property as a Qt property named
     * '%(adaptee_name)s' with type %(type)s.
     *
%(docstring)s\
     *
     * \\return The value of exported property \\c %(name)s.
     */
    %(type)s %(gettername)s() const;
""" % {'name': name,
       'adaptee_name': adaptee_name,
       'docstring': docstring,
       'type': binding.val,
       'gettername': gettername,
       })

            self.b("""
%(type)s %(ifacename)s::%(gettername)s() const
{
    return qvariant_cast< %(type)s >(adaptee()->property("%(adaptee_name)s"));
}
""" % {'type': binding.val,
       'ifacename': ifacename,
       'gettername': gettername,
       'adaptee_name': adaptee_name,
       })

        if 'write' in access:
            self.h("""\
    /**
     * Set the value of the exported D-Bus object property \\c %(name)s of type \\c %(type)s.
     *
     * Adaptees should export this property as a writable Qt property named
     * '%(adaptee_name)s' with type %(type)s.
     *
%(docstring)s\
     */
    void %(settername)s(const %(type)s &newValue);
""" % {'name': name,
       'adaptee_name': adaptee_name,
       'docstring': docstring,
       'settername': settername,
       'type': binding.val,
       })

            self.b("""
void %(ifacename)s::%(settername)s(const %(type)s &newValue)
{
    adaptee()->setProperty("%(adaptee_name)s", qVariantFromValue(newValue));
}
""" % {'ifacename': ifacename,
       'settername': settername,
       'type': binding.val,
       'adaptee_name': adaptee_name,
       })