Re: [libgpiod][PATCH v2 3/3] bindings: cxx: implement C++ bindings for libgpiod v2.0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 16, 2021 at 10:56 AM Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
>
> On Fri, Jul 16, 2021 at 9:44 AM Bartosz Golaszewski <brgl@xxxxxxxx> wrote:
> >
> > On Fri, Jul 16, 2021 at 12:18 AM Ben Hutchings
> > <ben.hutchings@xxxxxxxxxxxxx> wrote:
> > >
> > > On Thu, Jul 15, 2021 at 10:10:01PM +0200, Bartosz Golaszewski wrote:
> > > > This is the bulk of work implementing C++ bindings for the new libgpiod
> > > > API. The tests are not converted yet but the examples are fully
> > > > functional. More details in the cover letter as this patch will be
> > > > squashed with the one for the core C library anyway.
> > > [...]
> > > > +class line_config
> > > > +{
> > > > +public:
> > > > +
> > > > +     /**
> > > > +      * @brief Direction settings.
> > > > +      */
> > > > +     enum : int {
> > > > +             DIRECTION_AS_IS = 1,
> > > > +             /**< Request the line(s), but don't change current direction. */
> > > > +             DIRECTION_INPUT,
> > > > +             /**< Request the line(s) for reading the GPIO line state. */
> > > > +             DIRECTION_OUTPUT
> > > > +             /**< Request the line(s) for setting the GPIO line state. */
> > > > +     };
> > > [...]
> > > > +class line_info
> > > > +{
> > > > +public:
> > > > +
> > > > +     /**
> > > > +      * @brief Direction settings.
> > > > +      */
> > > > +     enum : int {
> > > > +             DIRECTION_INPUT = 1,
> > > > +             /**< Direction is input - we're reading the state of a GPIO line. */
> > > > +             DIRECTION_OUTPUT
> > > > +             /**< Direction is output - we're driving the GPIO line. */
> > > > +     };
> > > [...]
> > >
> > > Could these be enum class types, or does that introduce an ABI issue
> > > if you extend them later?
> > >
> > > Ben.
> >
> > I'm not sure there would be any benefit to enum classes here except
> > for longer scope when using them in code. I would prefer to leave it
> > this way.
> >
> > Bartosz
>
> Actually after a second thought, it wouldn't make it long - it would
> just look like: line_info::direction::INPUT instead. Maybe it is a
> more C++ approach after all.
>
> Bart

I tried to change it but if - for example - I implement the enum type
for the direction property of line_info as:

enum class direction {
    INPUT = 1,
    OUTPUT
};

then it conflicts with the getter of line_info: direction(void) const.

One option is to rename all getters to get_<property>(). What do you think?

Bartosz



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux