[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 44/58] qom: provide convenient macros for declaring and de
From: |
Eduardo Habkost |
Subject: |
Re: [PATCH v2 44/58] qom: provide convenient macros for declaring and defining types |
Date: |
Thu, 20 Aug 2020 14:48:30 -0400 |
On Thu, Aug 20, 2020 at 06:57:33PM +0100, Daniel P. Berrangé wrote:
> On Thu, Aug 20, 2020 at 01:45:06PM -0400, Eduardo Habkost wrote:
> > (CCing Eric Blake, who reviewed the original patch. Sorry for
> > not CCing you previously, Eric)
> >
> > On Wed, Aug 19, 2020 at 08:12:22PM -0400, Eduardo Habkost wrote:
> > [...]
> > > +/**
> > > + * OBJECT_DECLARE_TYPE:
> > > + * @ModuleObjName: the object name with initial capitalization
> > > + * @module_obj_name: the object name in lowercase with underscore
> > > separators
> > > + * @MODULE_OBJ_NAME: the object name in uppercase with underscore
> > > separators
> >
> > We need to decide what to do with TYPE_SWIM:
> >
> > #define TYPE_SWIM "swim"
> > typedef struct SWIM SWIM;
> > #define SWIM(obj) OBJECT_CHECK(SWIM, (obj), TYPE_SWIM)
> >
> > Both the typedef and type checking macros are called "SWIM".
> > This makes usage of OBJECT_DECLARE_TYPE impossible (because the
> > type checking function can't have the same as the typedef). What
> > should be the recommended style here? Rename the struct to
> > "Swim"?
>
> This would be the gobject style approach to the problem - structs
> always have initial-caps-only even if they are abbreviations.
>
> If that's unappealing we could add a suffix "struct SWIMInst"
I was considering "SWIMState", because "State" is a common
instance type suffix in QEMU device code. But I will let the
maintainer (Laurent) decide.
>
> > We have similar issues with RXCPU and ARMSSE, but these type
> > checking macros can be easily renamed to RX_CPU and ARM_SSE. so
> > they won't be an issue.
>
> Or RSCPUInst and ARMSSEInst ?
In these cases, renaming the type checking macro seems more
logical, because the type name constants are TYPE_RX_CPU and
TYPE_ARM_SSE.
--
Eduardo
- Re: [PATCH v2 42/58] vfio/pci: Move QOM macros to header, (continued)
- [PATCH v2 43/58] qom: make object_ref/unref use a void * instead of Object *., Eduardo Habkost, 2020/08/19
- [PATCH v2 45/58] qom: Allow class type name to be specified in OBJECT_DECLARE*, Eduardo Habkost, 2020/08/19
- [PATCH v2 47/58] qom: Make type checker functions accept const pointers, Eduardo Habkost, 2020/08/19
- [PATCH v2 46/58] qom: DECLARE_*_CHECKERS macros, Eduardo Habkost, 2020/08/19
- [PATCH v2 48/58] qom: TYPE_INFO macro, Eduardo Habkost, 2020/08/19
- [PATCH v2 50/58] [automated] Delete duplicate QOM typedefs, Eduardo Habkost, 2020/08/19
- [PATCH v2 44/58] qom: provide convenient macros for declaring and defining types, Eduardo Habkost, 2020/08/19
- [PATCH v2 54/58] [semi-automated] Use DECLARE_*CHECKER* when possible (--force mode), Eduardo Habkost, 2020/08/19
- [PATCH v2 56/58] [automated] Use OBJECT_DECLARE_SIMPLE_TYPE when possible, Eduardo Habkost, 2020/08/19
- [PATCH v2 55/58] [automated] Use OBJECT_DECLARE_TYPE where possible, Eduardo Habkost, 2020/08/19
- [PATCH v2 58/58] crypto: use QOM macros for declaration/definition of TLS creds types, Eduardo Habkost, 2020/08/19
- [PATCH v2 57/58] crypto: use QOM macros for declaration/definition of secret types, Eduardo Habkost, 2020/08/19
- [PATCH v2 53/58] [automated] Use DECLARE_*CHECKER* macros, Eduardo Habkost, 2020/08/19