kwaylandScanner produce version enum per class
Needs ReviewPublic

Authored by gladhorn on Sep 16 2019, 6:57 PM.

Details

Reviewers
None
Group Reviewers
KWin
Summary

Otherwise it only creates the enum for the first class encountered.

Diff Detail

Repository
R127 KWayland
Branch
master
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 16649
Build 16667: arc lint + arc unit
gladhorn created this revision.Sep 16 2019, 6:57 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptSep 16 2019, 6:57 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
gladhorn requested review of this revision.Sep 16 2019, 6:57 PM
zzag added a subscriber: zzag.Sep 16 2019, 7:44 PM
src/tools/generator.cpp
431

Is it correct thogugh? Can you provide some test input so it's easier to see the problem?

The unstable primary selection v1 protocol produces code that doesn't compile, after this change it does compile - since it expects the version enums for three classes, but only the first one is actually written into the file.

gladhorn marked an inline comment as done.Sep 20 2019, 1:25 PM
gladhorn added inline comments.
src/tools/generator.cpp
431

run kwaylandScanner on /usr/share/wayland-protocols/unstable/primary-selection/primary-selection-unstable-v1.xml and see that it produces something that doesn't compile. With this change it compiles.

Header output with the patch:

#ifndef KWAYLAND_SERVER_WP_PRIMARY_SELECTION_UNSTABLE_V1_H
#define KWAYLAND_SERVER_WP_PRIMARY_SELECTION_UNSTABLE_V1_H

#include "global.h"
#include "resource.h"

#include <KWayland/Server/kwaylandserver_export.h>

namespace KWayland
{
namespace Server
{

class Display;

/**
 * Enum describing the interface versions the PrimarySelectionDeviceManagerV1Interface can support.
 *
 * @since 5.XX
 **/
enum class PrimarySelectionDeviceManagerV1InterfaceVersion {
    /**
     * zwp_primary_selection_device_manager_v1
     **/
     UnstableV1
};

/**
 * Enum describing the interface versions the PrimarySelectionDeviceV1Interface can support.
 *
 * @since 5.XX
 **/
enum class PrimarySelectionDeviceV1InterfaceVersion {
    /**
     * zwp_primary_selection_device_v1
     **/
     UnstableV1
};

/**
 * Enum describing the interface versions the PrimarySelectionOfferV1Interface can support.
 *
 * @since 5.XX
 **/
enum class PrimarySelectionOfferV1InterfaceVersion {
    /**
     * zwp_primary_selection_offer_v1
     **/
     UnstableV1
};

/**
 * Enum describing the interface versions the PrimarySelectionSourceV1Interface can support.
 *
 * @since 5.XX
 **/
enum class PrimarySelectionSourceV1InterfaceVersion {
    /**
     * zwp_primary_selection_source_v1
     **/
     UnstableV1
};

class KWAYLANDSERVER_EXPORT PrimarySelectionDeviceManagerV1Interface : public Global
{
    Q_OBJECT
public:
    virtual ~PrimarySelectionDeviceManagerV1Interface();

    /**
     * @returns The interface version used by this PrimarySelectionDeviceManagerV1Interface
     **/
    PrimarySelectionDeviceManagerV1InterfaceVersion interfaceVersion() const;

protected:
    class Private;
    explicit PrimarySelectionDeviceManagerV1Interface(Private *d, QObject *parent = nullptr);

private:
    Private *d_func() const;
};

class KWAYLANDSERVER_EXPORT PrimarySelectionDeviceV1Interface : public Resource
{
    Q_OBJECT
public:

    virtual ~PrimarySelectionDeviceV1Interface();

    /**
     * @returns The interface version used by this PrimarySelectionDeviceV1Interface
     **/
    PrimarySelectionDeviceManagerV1InterfaceVersion interfaceVersion() const;

protected:
    class Private;
    explicit PrimarySelectionDeviceV1Interface(Private *p, QObject *parent = nullptr);

private:
    Private *d_func() const;
};

class KWAYLANDSERVER_EXPORT PrimarySelectionOfferV1Interface : public Global
{
    Q_OBJECT
public:
    virtual ~PrimarySelectionOfferV1Interface();

    /**
     * @returns The interface version used by this PrimarySelectionOfferV1Interface
     **/
    PrimarySelectionOfferV1InterfaceVersion interfaceVersion() const;

protected:
    class Private;
    explicit PrimarySelectionOfferV1Interface(Private *d, QObject *parent = nullptr);

private:
    Private *d_func() const;
};

class KWAYLANDSERVER_EXPORT PrimarySelectionSourceV1Interface : public Resource
{
    Q_OBJECT
public:

    virtual ~PrimarySelectionSourceV1Interface();

    /**
     * @returns The interface version used by this PrimarySelectionSourceV1Interface
     **/
    PrimarySelectionDeviceManagerV1InterfaceVersion interfaceVersion() const;

protected:
    class Private;
    explicit PrimarySelectionSourceV1Interface(Private *p, QObject *parent = nullptr);

private:
    Private *d_func() const;
};


}
}

#endif

Without it just the first enum is generated.

That being said only two of the four defined enums are actually used in the above skeleton and normally only one enum is defined which then determines all interfaces created by the manager. See for example:
https://cgit.kde.org/kwayland.git/tree/src/server/textinput_interface.h

Mixing different versions does not make sense so it's enough to have one enum for all interfaces.

romangg added a comment.EditedSep 20 2019, 2:49 PM

By the way I guess the reason why the PrimarySelectionOfferV1InterfaceVersion is there even without the patch but not the other interfaces is that the other interfaces are created through the manager on request of the client while the offer is created server-side and then sent through an event to client.