mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-12 10:04:14 +02:00
Add OBJECT_DEFINE_GET() macro to define object getters.
Simple object getters involve a lot of boilerplate code so create a macro to simplify implementing them.
This commit is contained in:
parent
da43db3543
commit
abb7639807
@ -34,6 +34,27 @@ Create a local "this" variable of the correct type from a THIS_VOID parameter
|
||||
***********************************************************************************************************************************/
|
||||
#define THIS(type) type *this = thisVoid
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Define a function used to get an object member variable.
|
||||
|
||||
If the object type/prefix is "Object"/"object" then the macro:
|
||||
|
||||
OBJECT_DEFINE_GET(Size, const, OBJECT, size_t, size);
|
||||
|
||||
will define the function as:
|
||||
|
||||
size_t objectSize(const Object *this)
|
||||
|
||||
No function logging in required because no functions can be called which means no errors can be thrown.
|
||||
***********************************************************************************************************************************/
|
||||
#define OBJECT_DEFINE_GET(name, objectQualifier, objectMacro, returnType, objectMember) \
|
||||
returnType \
|
||||
GLUE(objectMacro##_PREFIX, name)(objectQualifier objectMacro##_TYPE *this) \
|
||||
{ \
|
||||
ASSERT(this != NULL); \
|
||||
return this->objectMember; \
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Define a function used by the caller to move an object from one context to another
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user