C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Attributes introspection

From: Aurelien Cassagnes <aurelien.cassagnes_at_[hidden]>
Date: Sat, 20 Apr 2024 11:44:52 +0900
I will continue this discussion in SG7 as proposed above, with an ongoing
draft.
Thanks for the feedback

Le lun. 15 avr. 2024 à 22:24, Giuseppe D'Angelo via Std-Proposals <
std-proposals_at_[hidden]> a écrit :

> On 15/04/2024 14:02, Sebastian Wittmeier via Std-Proposals wrote:
> > perhaps a small reference to the effect of attributes is suitable, as
> > this proposal slightly changes the potential effects of attributes.
> >
> > If generic code reacts to whether certain attributes are present, then
> > attributes can have a direct effect on what a program does.
> >
> > It is perhaps acceptable, as it is the program (+libraries) itself
> > looking at its own (+libraries') attributes, but it is a slight shift
> > from "attributes can just be ignored".
> >
> > Currently the standards committees can make sure, how attributes are
> used.
>
> *Standard* attributes are under the ignorability rules, but
> vendor-specific or library-specific attributes can do whatever they
> want. In Qt we use a preprocessing tool (moc) to generate metadata for a
> given class (and generate some supporting code); the metadata that the
> user wants to extract is marked by macros that normally expand to
> nothing. It wouldn't be too far fetched to want to turn those macros
> into C++ attributes, and use (generative) reflection instead.
>
> Something like:
>
> >
> +--------------------------------------------------------------------------+----------------------------------------------------------------------+
> > | Now
> | After |
> >
> +--------------------------------------------------------------------------+----------------------------------------------------------------------+
> > | class MyClass : public QObject
> | class MyClass : public QObject |
> > | {
> | { |
> > | Q_OBJECT
> | Q_OBJECT |
> > |
> | |
> > | Q_PROPERTY(int speed READ getSpeed WRITE setSpeed NOTIFY
> speedChanged) | [[qt::property(READ getSpeed WRITE setSpeed NOTIFY
> speedChanged)]] |
> > | int m_speed;
> | QProperty<int> m_speed; |
> > |
> | |
> > | enum class E { A, B };
> | [[qt::enum]] |
> > | Q_ENUM(E);
> | enum class E { A, B }; |
> > |
> | |
> > | public:
> | public: |
> > | MyClass();
> | MyClass(); |
> > |
> | |
> > | Q_SLOT void doSomething();
> | [[qt::slot]] void doSomething(); |
> > |
> | |
> > | int getSpeed() const;
> | int getSpeed() const; |
> > | void setSpeed(int);
> | void setSpeed(int); |
> > |
> | |
> > | Q_SIGNAL void speedChanged();
> | [[qt::signal]] void speedChanged(); |
> > | };
> | }; |
> >
> +--------------------------------------------------------------------------+----------------------------------------------------------------------+
>
>
> My 2 c,
> --
> Giuseppe D'Angelo
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2024-04-20 02:45:06