1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-03 14:52:21 +02:00

Add THIS_PUB() macro to simplify inline object accessors.

In combination with the thisPub() function, this macro simplifies accessing the public part of a private object struct.

thisPub() asserts this != NULL so the caller does not need to do it.
This commit is contained in:
David Steele 2021-04-13 16:58:02 -04:00
parent 9fec4ce98c
commit a0e24d492f
33 changed files with 132 additions and 209 deletions

View File

@ -219,12 +219,13 @@ typedef struct ListPub
// List size
__attribute__((always_inline)) static inline unsigned int
lstSize(const List *this)
lstSize(const List *const this)
{
ASSERT_INLINE(this != NULL);
return ((const ListPub *)this)->listSize;
return THIS_PUB(List)->listSize;
}
```
`THIS_PUB()` ensures that `this != NULL` so there is no need to check that in the calling function.
And the C file:
```c
struct List

View File

@ -282,13 +282,14 @@ typedef struct ListPub
// List size
__attribute__((always_inline)) static inline unsigned int
lstSize(const List *this)
lstSize(const List *const this)
{
ASSERT_INLINE(this != NULL);
return ((const ListPub *)this)->listSize;
return THIS_PUB(List)->listSize;
}
</code-block>
<p><code>THIS_PUB()</code> ensures that <code>this != NULL</code> so there is no need to check that in the calling function.</p>
<p>And the C file:</p>
<code-block type="c">

View File

@ -38,24 +38,21 @@ typedef struct DbPub
__attribute__((always_inline)) static inline IoRead *
execIoRead(Exec *const this)
{
ASSERT_INLINE(this != NULL);
return ((ExecPub *)this)->ioReadExec;
return THIS_PUB(Exec)->ioReadExec;
}
// Write interface
__attribute__((always_inline)) static inline IoWrite *
execIoWrite(Exec *const this)
{
ASSERT_INLINE(this != NULL);
return ((ExecPub *)this)->ioWriteExec;
return THIS_PUB(Exec)->ioWriteExec;
}
// Exec MemContext
__attribute__((always_inline)) static inline MemContext *
execMemContext(Exec *const this)
{
ASSERT_INLINE(this != NULL);
return ((ExecPub *)this)->memContext;
return THIS_PUB(Exec)->memContext;
}
/***********************************************************************************************************************************

View File

@ -30,8 +30,7 @@ typedef struct IoClientPub
__attribute__((always_inline)) static inline const String *
ioClientName(const IoClient *const this)
{
ASSERT_INLINE(this != NULL);
return ((const IoClientPub *)this)->interface->name(((const IoClientPub *)this)->driver);
return THIS_PUB(IoClient)->interface->name(THIS_PUB(IoClient)->driver);
}
/***********************************************************************************************************************************
@ -48,8 +47,7 @@ ioClientMove(IoClient *this, MemContext *parentNew)
__attribute__((always_inline)) static inline IoSession *
ioClientOpen(IoClient *const this)
{
ASSERT_INLINE(this != NULL);
return ((const IoClientPub *)this)->interface->open(((const IoClientPub *)this)->driver);
return THIS_PUB(IoClient)->interface->open(THIS_PUB(IoClient)->driver);
}
/***********************************************************************************************************************************

View File

@ -31,8 +31,7 @@ Variant *ioFilterResult(const IoFilter *this);
__attribute__((always_inline)) static inline const String *
ioFilterType(const IoFilter *const this)
{
ASSERT_INLINE(this != NULL);
return ((IoFilterPub *)this)->type;
return THIS_PUB(IoFilter)->type;
}
/***********************************************************************************************************************************

View File

@ -72,8 +72,7 @@ bool ioFilterDone(const IoFilter *this);
__attribute__((always_inline)) static inline void *
ioFilterDriver(IoFilter *const this)
{
ASSERT_INLINE(this != NULL);
return ((IoFilterPub *)this)->driver;
return THIS_PUB(IoFilter)->driver;
}
// Does the filter need the same input again? If the filter cannot get all its output into the output buffer then it may need access
@ -84,24 +83,21 @@ bool ioFilterInputSame(const IoFilter *this);
__attribute__((always_inline)) static inline const IoFilterInterface *
ioFilterInterface(const IoFilter *const this)
{
ASSERT_INLINE(this != NULL);
return &((IoFilterPub *)this)->interface;
return &THIS_PUB(IoFilter)->interface;
}
// Does filter produce output? All In filters produce output.
__attribute__((always_inline)) static inline bool
ioFilterOutput(const IoFilter *const this)
{
ASSERT_INLINE(this != NULL);
return ((IoFilterPub *)this)->interface.inOut != NULL;
return THIS_PUB(IoFilter)->interface.inOut != NULL;
}
// List of filter parameters
__attribute__((always_inline)) static inline const VariantList *
ioFilterParamList(const IoFilter *const this)
{
ASSERT_INLINE(this != NULL);
return ((IoFilterPub *)this)->paramList;
return THIS_PUB(IoFilter)->paramList;
}
/***********************************************************************************************************************************

View File

@ -44,9 +44,8 @@ typedef struct IoFilterGroupPub
__attribute__((always_inline)) static inline bool
ioFilterGroupDone(const IoFilterGroup *const this)
{
ASSERT_INLINE(this != NULL);
ASSERT_INLINE(((IoFilterGroupPub *)this)->opened && !((IoFilterGroupPub *)this)->closed);
return ((IoFilterGroupPub *)this)->done;
ASSERT_INLINE(THIS_PUB(IoFilterGroup)->opened && !THIS_PUB(IoFilterGroup)->closed);
return THIS_PUB(IoFilterGroup)->done;
}
// Should the same input be passed again? A buffer of input can produce multiple buffers of output, e.g. when a file containing all
@ -54,9 +53,8 @@ ioFilterGroupDone(const IoFilterGroup *const this)
__attribute__((always_inline)) static inline bool
ioFilterGroupInputSame(const IoFilterGroup *const this)
{
ASSERT_INLINE(this != NULL);
ASSERT_INLINE(((IoFilterGroupPub *)this)->opened && !((IoFilterGroupPub *)this)->closed);
return ((IoFilterGroupPub *)this)->inputSame;
ASSERT_INLINE(THIS_PUB(IoFilterGroup)->opened && !THIS_PUB(IoFilterGroup)->closed);
return THIS_PUB(IoFilterGroup)->inputSame;
}
// Get all filters and their parameters so they can be passed to a remote
@ -73,8 +71,7 @@ void ioFilterGroupResultAllSet(IoFilterGroup *this, const Variant *filterResult)
__attribute__((always_inline)) static inline unsigned int
ioFilterGroupSize(const IoFilterGroup *const this)
{
ASSERT_INLINE(this != NULL);
return lstSize(((IoFilterGroupPub *)this)->filterList);
return lstSize(THIS_PUB(IoFilterGroup)->filterList);
}
/***********************************************************************************************************************************

View File

@ -55,8 +55,7 @@ typedef struct HttpClientPub
__attribute__((always_inline)) static inline TimeMSec
httpClientTimeout(const HttpClient *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpClientPub *)this)->timeout;
return THIS_PUB(HttpClient)->timeout;
}
/***********************************************************************************************************************************

View File

@ -91,32 +91,28 @@ typedef struct HttpRequestPub
__attribute__((always_inline)) static inline const String *
httpRequestPath(const HttpRequest *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpRequestPub *)this)->path;
return THIS_PUB(HttpRequest)->path;
}
// Request query
__attribute__((always_inline)) static inline const HttpQuery *
httpRequestQuery(const HttpRequest *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpRequestPub *)this)->query;
return THIS_PUB(HttpRequest)->query;
}
// Request headers
__attribute__((always_inline)) static inline const HttpHeader *
httpRequestHeader(const HttpRequest *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpRequestPub *)this)->header;
return THIS_PUB(HttpRequest)->header;
}
// Request verb
__attribute__((always_inline)) static inline const String *
httpRequestVerb(const HttpRequest *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpRequestPub *)this)->verb;
return THIS_PUB(HttpRequest)->verb;
}
/***********************************************************************************************************************************

View File

@ -46,32 +46,28 @@ typedef struct HttpResponsePub
__attribute__((always_inline)) static inline IoRead *
httpResponseIoRead(HttpResponse *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpResponsePub *)this)->contentRead;
return THIS_PUB(HttpResponse)->contentRead;
}
// Response code
__attribute__((always_inline)) static inline unsigned int
httpResponseCode(const HttpResponse *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpResponsePub *)this)->code;
return THIS_PUB(HttpResponse)->code;
}
// Response headers
__attribute__((always_inline)) static inline const HttpHeader *
httpResponseHeader(const HttpResponse *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpResponsePub *)this)->header;
return THIS_PUB(HttpResponse)->header;
}
// Response reason
__attribute__((always_inline)) static inline const String *
httpResponseReason(const HttpResponse *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpResponsePub *)this)->reason;
return THIS_PUB(HttpResponse)->reason;
}
/***********************************************************************************************************************************

View File

@ -56,40 +56,35 @@ typedef struct HttpUrlPub
__attribute__((always_inline)) static inline HttpProtocolType
httpUrlProtocolType(const HttpUrl *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpUrlPub *)this)->type;
return THIS_PUB(HttpUrl)->type;
}
// Host
__attribute__((always_inline)) static inline const String *
httpUrlHost(const HttpUrl *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpUrlPub *)this)->host;
return THIS_PUB(HttpUrl)->host;
}
// Path
__attribute__((always_inline)) static inline const String *
httpUrlPath(const HttpUrl *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpUrlPub *)this)->path;
return THIS_PUB(HttpUrl)->path;
}
// Port
__attribute__((always_inline)) static inline unsigned int
httpUrlPort(const HttpUrl *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpUrlPub *)this)->port;
return THIS_PUB(HttpUrl)->port;
}
// URL (exactly as originally passed)
__attribute__((always_inline)) static inline const String *
httpUrl(const HttpUrl *this)
{
ASSERT_INLINE(this != NULL);
return ((const HttpUrlPub *)this)->url;
return THIS_PUB(HttpUrl)->url;
}
/***********************************************************************************************************************************

View File

@ -26,25 +26,22 @@ Getters/Setters
__attribute__((always_inline)) static inline bool
ioReadBlock(const IoRead *const this)
{
ASSERT_INLINE(this != NULL);
return ((IoReadPub *)this)->interface.block;
return THIS_PUB(IoRead)->interface.block;
}
// Is IO at EOF? All driver reads are complete and all data has been flushed from the filters (if any).
__attribute__((always_inline)) static inline bool
ioReadEof(const IoRead *const this)
{
ASSERT_INLINE(this != NULL);
ASSERT_INLINE(((IoReadPub *)this)->opened && !((IoReadPub *)this)->closed);
return ((const IoReadPub *)this)->eofAll;
ASSERT_INLINE(THIS_PUB(IoRead)->opened && !THIS_PUB(IoRead)->closed);
return THIS_PUB(IoRead)->eofAll;
}
// Get filter group if filters need to be added
__attribute__((always_inline)) static inline IoFilterGroup *
ioReadFilterGroup(IoRead *const this)
{
ASSERT_INLINE(this != NULL);
return ((IoReadPub *)this)->filterGroup;
return THIS_PUB(IoRead)->filterGroup;
}
// File descriptor for the read object. Not all read objects have a file descriptor and -1 will be returned in that case.
@ -69,7 +66,6 @@ String *ioReadLineParam(IoRead *this, bool allowEof);
__attribute__((always_inline)) static inline String *
ioReadLine(IoRead *const this)
{
ASSERT_INLINE(this != NULL);
return ioReadLineParam(this, false);
}

View File

@ -53,16 +53,14 @@ typedef struct IoReadPub
__attribute__((always_inline)) static inline void *
ioReadDriver(IoRead *const this)
{
ASSERT_INLINE(this != NULL);
return ((IoReadPub *)this)->driver;
return THIS_PUB(IoRead)->driver;
}
// Interface for the read object
__attribute__((always_inline)) static inline const IoReadInterface *
ioReadInterface(const IoRead *this)
{
ASSERT_INLINE(this != NULL);
return &((IoReadPub *)this)->interface;
return &THIS_PUB(IoRead)->interface;
}
/***********************************************************************************************************************************

View File

@ -43,24 +43,21 @@ int ioSessionFd(IoSession *this);
__attribute__((always_inline)) static inline IoRead *
ioSessionIoRead(IoSession *const this)
{
ASSERT_INLINE(this != NULL);
return ((IoSessionPub *)this)->interface->ioRead(((IoSessionPub *)this)->driver);
return THIS_PUB(IoSession)->interface->ioRead(THIS_PUB(IoSession)->driver);
}
// Write interface
__attribute__((always_inline)) static inline IoWrite *
ioSessionIoWrite(IoSession *const this)
{
ASSERT_INLINE(this != NULL);
return ((IoSessionPub *)this)->interface->ioWrite(((IoSessionPub *)this)->driver);
return THIS_PUB(IoSession)->interface->ioWrite(THIS_PUB(IoSession)->driver);
}
// Session role
__attribute__((always_inline)) static inline IoSessionRole
ioSessionRole(const IoSession *const this)
{
ASSERT_INLINE(this != NULL);
return ((const IoSessionPub *)this)->interface->role(((const IoSessionPub *)this)->driver);
return THIS_PUB(IoSession)->interface->role(THIS_PUB(IoSession)->driver);
}
/***********************************************************************************************************************************
@ -70,8 +67,7 @@ Functions
__attribute__((always_inline)) static inline void
ioSessionClose(IoSession *const this)
{
ASSERT_INLINE(this != NULL);
return ((IoSessionPub *)this)->interface->close(((IoSessionPub *)this)->driver);
return THIS_PUB(IoSession)->interface->close(THIS_PUB(IoSession)->driver);
}
// Move to a new parent mem context

View File

@ -31,8 +31,7 @@ typedef struct IoWritePub
__attribute__((always_inline)) static inline IoFilterGroup *
ioWriteFilterGroup(IoWrite *const this)
{
ASSERT_INLINE(this != NULL);
return ((IoWritePub *)this)->filterGroup;
return THIS_PUB(IoWrite)->filterGroup;
}
// File descriptor for the write object. Not all write objects have a file descriptor and -1 will be returned in that case.

View File

@ -36,8 +36,7 @@ typedef struct KeyValuePub
__attribute__((always_inline)) static inline const VariantList *
kvKeyList(const KeyValue *const this)
{
ASSERT_INLINE(this != NULL);
return ((KeyValuePub *)this)->keyList;
return THIS_PUB(KeyValue)->keyList;
}
/***********************************************************************************************************************************

View File

@ -77,16 +77,14 @@ List *lstComparatorSet(List *this, ListComparator *comparator);
__attribute__((always_inline)) static inline MemContext *
lstMemContext(const List *this)
{
ASSERT_INLINE(this != NULL);
return ((const ListPub *)this)->memContext;
return THIS_PUB(List)->memContext;
}
// List size
__attribute__((always_inline)) static inline unsigned int
lstSize(const List *this)
{
ASSERT_INLINE(this != NULL);
return ((const ListPub *)this)->listSize;
return THIS_PUB(List)->listSize;
}
// Is the list empty?

View File

@ -6,6 +6,7 @@ These macros and functions implement common object functionality.
#ifndef COMMON_TYPE_OBJECT_H
#define COMMON_TYPE_OBJECT_H
#include "common/assert.h"
#include "common/memContext.h"
/***********************************************************************************************************************************
@ -22,6 +23,27 @@ Create a local "this" variable of the correct type from a THIS_VOID parameter
***********************************************************************************************************************************/
#define THIS(type) type *this = thisVoid
/***********************************************************************************************************************************
Cast this private struct, e.g. List, to the associated public struct, e.g. ListPub. Note that the public struct must be the first
member of the private struct. For example:
__attribute__((always_inline)) static inline unsigned int
lstSize(const List *const this)
{
return THIS_PUB(List)->listSize;
}
The macro also ensures that this != NULL so there is no need to do that in the calling function.
***********************************************************************************************************************************/
#define THIS_PUB(type) ((type##Pub *)thisNotNull(this))
__attribute__((always_inline)) static inline const void *
thisNotNull(const void *const this)
{
ASSERT_INLINE(this != NULL);
return this;
}
/***********************************************************************************************************************************
Functions

View File

@ -45,7 +45,6 @@ Buffer *xmlDocumentBuf(const XmlDocument *this);
__attribute__((always_inline)) static inline XmlNode *
xmlDocumentRoot(const XmlDocument *const this)
{
ASSERT_INLINE(this != NULL);
return ((XmlDocumentPub *const)this)->root;
}

View File

@ -30,8 +30,7 @@ typedef struct WaitPub
__attribute__((always_inline)) static inline TimeMSec
waitRemaining(const Wait *this)
{
ASSERT_INLINE(this != NULL);
return ((const WaitPub *)this)->remainTime;
return THIS_PUB(Wait)->remainTime;
}
/***********************************************************************************************************************************

View File

@ -37,32 +37,28 @@ typedef struct DbPub
__attribute__((always_inline)) static inline const String *
dbArchiveMode(const Db *const this)
{
ASSERT_INLINE(this != NULL);
return ((DbPub *)this)->archiveMode;
return THIS_PUB(Db)->archiveMode;
}
// Archive command loaded from the archive_command GUC
__attribute__((always_inline)) static inline const String *
dbArchiveCommand(const Db *const this)
{
ASSERT_INLINE(this != NULL);
return ((DbPub *)this)->archiveCommand;
return THIS_PUB(Db)->archiveCommand;
}
// Data path loaded from the data_directory GUC
__attribute__((always_inline)) static inline const String *
dbPgDataPath(const Db *const this)
{
ASSERT_INLINE(this != NULL);
return ((DbPub *)this)->pgDataPath;
return THIS_PUB(Db)->pgDataPath;
}
// Version loaded from the server_version_num GUC
__attribute__((always_inline)) static inline unsigned int
dbPgVersion(const Db *const this)
{
ASSERT_INLINE(this != NULL);
return ((DbPub *)this)->pgVersion;
return THIS_PUB(Db)->pgVersion;
}
/***********************************************************************************************************************************

View File

@ -55,8 +55,7 @@ typedef struct InfoPub
__attribute__((always_inline)) static inline const String *
infoCipherPass(const Info *const this)
{
ASSERT_INLINE(this != NULL);
return ((InfoPub *)this)->cipherPass;
return THIS_PUB(Info)->cipherPass;
}
void infoCipherPassSet(Info *this, const String *cipherPass);
@ -65,8 +64,7 @@ void infoCipherPassSet(Info *this, const String *cipherPass);
__attribute__((always_inline)) static inline const String *
infoBackrestVersion(const Info *const this)
{
ASSERT_INLINE(this != NULL);
return ((InfoPub *)this)->backrestVersion;
return THIS_PUB(Info)->backrestVersion;
}
/***********************************************************************************************************************************

View File

@ -47,8 +47,7 @@ typedef struct InfoArchivePub
__attribute__((always_inline)) static inline InfoPg *
infoArchivePg(const InfoArchive *const this)
{
ASSERT_INLINE(this != NULL);
return ((InfoArchivePub *)this)->infoPg;
return THIS_PUB(InfoArchive)->infoPg;
}
InfoArchive *infoArchivePgSet(InfoArchive *this, unsigned int pgVersion, uint64_t pgSystemId);

View File

@ -77,8 +77,7 @@ typedef struct InfoBackupPub
__attribute__((always_inline)) static inline InfoPg *
infoBackupPg(const InfoBackup *const this)
{
ASSERT_INLINE(this != NULL);
return ((InfoBackupPub *)this)->infoPg;
return THIS_PUB(InfoBackup)->infoPg;
}
InfoBackup *infoBackupPgSet(InfoBackup *this, unsigned int pgVersion, uint64_t pgSystemId, unsigned int pgCatalogVersion);
@ -97,17 +96,15 @@ InfoBackupData infoBackupData(const InfoBackup *this, unsigned int backupDataIdx
__attribute__((always_inline)) static inline InfoBackupData *
infoBackupDataByLabel(const InfoBackup *const this, const String *const backupLabel)
{
ASSERT_INLINE(this != NULL);
ASSERT_INLINE(backupLabel != NULL);
return lstFind(((InfoBackupPub *)this)->backup, &backupLabel);
return lstFind(THIS_PUB(InfoBackup)->backup, &backupLabel);
}
// Get total current backups
__attribute__((always_inline)) static inline unsigned int
infoBackupDataTotal(const InfoBackup *const this)
{
ASSERT_INLINE(this != NULL);
return lstSize(((InfoBackupPub *)this)->backup);
return lstSize(THIS_PUB(InfoBackup)->backup);
}
/***********************************************************************************************************************************

View File

@ -66,8 +66,7 @@ String *infoPgArchiveId(const InfoPg *this, unsigned int pgDataIdx);
__attribute__((always_inline)) static inline Info *
infoPgInfo(const InfoPg *const this)
{
ASSERT_INLINE(this != NULL);
return ((InfoPgPub *)this)->info;
return THIS_PUB(InfoPg)->info;
}
// Return the cipher passphrase
@ -93,8 +92,7 @@ unsigned int infoPgDataCurrentId(const InfoPg *this);
__attribute__((always_inline)) static inline unsigned int
infoPgDataTotal(const InfoPg *const this)
{
ASSERT_INLINE(this != NULL);
return lstSize(((InfoPgPub *)this)->history);
return lstSize(THIS_PUB(InfoPg)->history);
}
/***********************************************************************************************************************************

View File

@ -177,23 +177,20 @@ typedef struct ManifestPub
__attribute__((always_inline)) static inline const String *
manifestCipherSubPass(const Manifest *const this)
{
ASSERT_INLINE(this != NULL);
return infoCipherPass(((const ManifestPub *)this)->info);
return infoCipherPass(THIS_PUB(Manifest)->info);
}
__attribute__((always_inline)) static inline void
manifestCipherSubPassSet(Manifest *const this, const String *const cipherSubPass)
{
ASSERT_INLINE(this != NULL);
infoCipherPassSet(((const ManifestPub *)this)->info, cipherSubPass);
infoCipherPassSet(THIS_PUB(Manifest)->info, cipherSubPass);
}
// Get manifest configuration and options
__attribute__((always_inline)) static inline const ManifestData *
manifestData(const Manifest *const this)
{
ASSERT_INLINE(this != NULL);
return &(((const ManifestPub *)this)->data);
return &(THIS_PUB(Manifest)->data);
}
// Set backup label
@ -240,8 +237,7 @@ Db functions and getters/setters
__attribute__((always_inline)) static inline const ManifestDb *
manifestDb(const Manifest *const this, const unsigned int dbIdx)
{
ASSERT_INLINE(this != NULL);
return lstGet(((const ManifestPub *)this)->dbList, dbIdx);
return lstGet(THIS_PUB(Manifest)->dbList, dbIdx);
}
const ManifestDb *manifestDbFind(const Manifest *this, const String *name);
@ -250,16 +246,14 @@ const ManifestDb *manifestDbFind(const Manifest *this, const String *name);
__attribute__((always_inline)) static inline const ManifestDb *
manifestDbFindDefault(const Manifest *const this, const String *const name, const ManifestDb *const dbDefault)
{
ASSERT_INLINE(this != NULL);
ASSERT_INLINE(name != NULL);
return lstFindDefault(((const ManifestPub *)this)->dbList, &name, (void *)dbDefault);
return lstFindDefault(THIS_PUB(Manifest)->dbList, &name, (void *)dbDefault);
}
__attribute__((always_inline)) static inline unsigned int
manifestDbTotal(const Manifest *const this)
{
ASSERT_INLINE(this != NULL);
return lstSize(((const ManifestPub *)this)->dbList);
return lstSize(THIS_PUB(Manifest)->dbList);
}
/***********************************************************************************************************************************
@ -268,8 +262,7 @@ File functions and getters/setters
__attribute__((always_inline)) static inline const ManifestFile *
manifestFile(const Manifest *const this, const unsigned int fileIdx)
{
ASSERT_INLINE(this != NULL);
return lstGet(((const ManifestPub *)this)->fileList, fileIdx);
return lstGet(THIS_PUB(Manifest)->fileList, fileIdx);
}
void manifestFileAdd(Manifest *this, const ManifestFile *file);
@ -279,9 +272,8 @@ const ManifestFile *manifestFileFind(const Manifest *this, const String *name);
__attribute__((always_inline)) static inline const ManifestFile *
manifestFileFindDefault(const Manifest *const this, const String *const name, const ManifestFile *const fileDefault)
{
ASSERT_INLINE(this != NULL);
ASSERT_INLINE(name != NULL);
return lstFindDefault(((const ManifestPub *)this)->fileList, &name, (void *)fileDefault);
return lstFindDefault(THIS_PUB(Manifest)->fileList, &name, (void *)fileDefault);
}
void manifestFileRemove(const Manifest *this, const String *name);
@ -289,8 +281,7 @@ void manifestFileRemove(const Manifest *this, const String *name);
__attribute__((always_inline)) static inline unsigned int
manifestFileTotal(const Manifest *const this)
{
ASSERT_INLINE(this != NULL);
return lstSize(((const ManifestPub *)this)->fileList);
return lstSize(THIS_PUB(Manifest)->fileList);
}
// Update a file with new data
@ -304,8 +295,7 @@ Link functions and getters/setters
__attribute__((always_inline)) static inline const ManifestLink *
manifestLink(const Manifest *const this, const unsigned int linkIdx)
{
ASSERT_INLINE(this != NULL);
return lstGet(((const ManifestPub *)this)->linkList, linkIdx);
return lstGet(THIS_PUB(Manifest)->linkList, linkIdx);
}
const ManifestLink *manifestLinkFind(const Manifest *this, const String *name);
@ -314,9 +304,8 @@ const ManifestLink *manifestLinkFind(const Manifest *this, const String *name);
__attribute__((always_inline)) static inline const ManifestLink *
manifestLinkFindDefault(const Manifest *const this, const String *const name, const ManifestLink *const linkDefault)
{
ASSERT_INLINE(this != NULL);
ASSERT_INLINE(name != NULL);
return lstFindDefault(((const ManifestPub *)this)->linkList, &name, (void *)linkDefault);
return lstFindDefault(THIS_PUB(Manifest)->linkList, &name, (void *)linkDefault);
}
void manifestLinkRemove(const Manifest *this, const String *name);
@ -324,8 +313,7 @@ void manifestLinkRemove(const Manifest *this, const String *name);
__attribute__((always_inline)) static inline unsigned int
manifestLinkTotal(const Manifest *const this)
{
ASSERT_INLINE(this != NULL);
return lstSize(((const ManifestPub *)this)->linkList);
return lstSize(THIS_PUB(Manifest)->linkList);
}
void manifestLinkUpdate(const Manifest *this, const String *name, const String *path);
@ -336,8 +324,7 @@ Path functions and getters/setters
__attribute__((always_inline)) static inline const ManifestPath *
manifestPath(const Manifest *const this, const unsigned int pathIdx)
{
ASSERT_INLINE(this != NULL);
return lstGet(((const ManifestPub *)this)->pathList, pathIdx);
return lstGet(THIS_PUB(Manifest)->pathList, pathIdx);
}
const ManifestPath *manifestPathFind(const Manifest *this, const String *name);
@ -346,9 +333,8 @@ const ManifestPath *manifestPathFind(const Manifest *this, const String *name);
__attribute__((always_inline)) static inline const ManifestPath *
manifestPathFindDefault(const Manifest *const this, const String *const name, const ManifestPath *const pathDefault)
{
ASSERT_INLINE(this != NULL);
ASSERT_INLINE(name != NULL);
return lstFindDefault(((const ManifestPub *)this)->pathList, &name, (void *)pathDefault);
return lstFindDefault(THIS_PUB(Manifest)->pathList, &name, (void *)pathDefault);
}
// Data directory relative path for any manifest file/link/path/target name
@ -357,8 +343,7 @@ String *manifestPathPg(const String *manifestPath);
__attribute__((always_inline)) static inline unsigned int
manifestPathTotal(const Manifest *const this)
{
ASSERT_INLINE(this != NULL);
return lstSize(((const ManifestPub *)this)->pathList);
return lstSize(THIS_PUB(Manifest)->pathList);
}
/***********************************************************************************************************************************
@ -367,8 +352,7 @@ Target functions and getters/setters
__attribute__((always_inline)) static inline const ManifestTarget *
manifestTarget(const Manifest *const this, const unsigned int targetIdx)
{
ASSERT_INLINE(this != NULL);
return lstGet(((const ManifestPub *)this)->targetList, targetIdx);
return lstGet(THIS_PUB(Manifest)->targetList, targetIdx);
}
const ManifestTarget *manifestTargetFind(const Manifest *this, const String *name);
@ -388,8 +372,7 @@ void manifestTargetRemove(const Manifest *this, const String *name);
__attribute__((always_inline)) static inline unsigned int
manifestTargetTotal(const Manifest *const this)
{
ASSERT_INLINE(this != NULL);
return lstSize(((const ManifestPub *)this)->targetList);
return lstSize(THIS_PUB(Manifest)->targetList);
}
void manifestTargetUpdate(const Manifest *this, const String *name, const String *path, const String *file);

View File

@ -56,16 +56,14 @@ typedef struct ProtocolClientPub
__attribute__((always_inline)) static inline IoRead *
protocolClientIoRead(ProtocolClient *this)
{
ASSERT_INLINE(this != NULL);
return ((ProtocolClientPub *)this)->read;
return THIS_PUB(ProtocolClient)->read;
}
// Write interface
__attribute__((always_inline)) static inline IoWrite *
protocolClientIoWrite(ProtocolClient *this)
{
ASSERT_INLINE(this != NULL);
return ((ProtocolClientPub *)this)->write;
return THIS_PUB(ProtocolClient)->write;
}
/***********************************************************************************************************************************

View File

@ -47,23 +47,20 @@ typedef struct ProtocolParallelJobPub
__attribute__((always_inline)) static inline const ProtocolCommand *
protocolParallelJobCommand(const ProtocolParallelJob *this)
{
ASSERT_INLINE(this != NULL);
return ((ProtocolParallelJobPub *)this)->command;
return THIS_PUB(ProtocolParallelJob)->command;
}
// Job error
__attribute__((always_inline)) static inline int
protocolParallelJobErrorCode(const ProtocolParallelJob *this)
{
ASSERT_INLINE(this != NULL);
return ((ProtocolParallelJobPub *)this)->code;
return THIS_PUB(ProtocolParallelJob)->code;
}
__attribute__((always_inline)) static inline const String *
protocolParallelJobErrorMessage(const ProtocolParallelJob *this)
{
ASSERT_INLINE(this != NULL);
return ((ProtocolParallelJobPub *)this)->message;
return THIS_PUB(ProtocolParallelJob)->message;
}
void protocolParallelJobErrorSet(ProtocolParallelJob *this, int code, const String *message);
@ -72,16 +69,14 @@ void protocolParallelJobErrorSet(ProtocolParallelJob *this, int code, const Stri
__attribute__((always_inline)) static inline const Variant *
protocolParallelJobKey(const ProtocolParallelJob *this)
{
ASSERT_INLINE(this != NULL);
return ((ProtocolParallelJobPub *)this)->key;
return THIS_PUB(ProtocolParallelJob)->key;
}
// Process Id
__attribute__((always_inline)) static inline unsigned int
protocolParallelJobProcessId(const ProtocolParallelJob *this)
{
ASSERT_INLINE(this != NULL);
return ((ProtocolParallelJobPub *)this)->processId;
return THIS_PUB(ProtocolParallelJob)->processId;
}
void protocolParallelJobProcessIdSet(ProtocolParallelJob *this, unsigned int processId);
@ -90,8 +85,7 @@ void protocolParallelJobProcessIdSet(ProtocolParallelJob *this, unsigned int pro
__attribute__((always_inline)) static inline const Variant *
protocolParallelJobResult(const ProtocolParallelJob *this)
{
ASSERT_INLINE(this != NULL);
return ((ProtocolParallelJobPub *)this)->result;
return THIS_PUB(ProtocolParallelJob)->result;
}
void protocolParallelJobResultSet(ProtocolParallelJob *this, const Variant *result);
@ -100,8 +94,7 @@ void protocolParallelJobResultSet(ProtocolParallelJob *this, const Variant *resu
__attribute__((always_inline)) static inline ProtocolParallelJobState
protocolParallelJobState(const ProtocolParallelJob *this)
{
ASSERT_INLINE(this != NULL);
return ((ProtocolParallelJobPub *)this)->state;
return THIS_PUB(ProtocolParallelJob)->state;
}
void protocolParallelJobStateSet(ProtocolParallelJob *this, ProtocolParallelJobState state);

View File

@ -48,16 +48,14 @@ typedef struct ProtocolServerPub
__attribute__((always_inline)) static inline IoRead *
protocolServerIoRead(ProtocolServer *this)
{
ASSERT_INLINE(this != NULL);
return ((ProtocolServerPub *)this)->read;
return THIS_PUB(ProtocolServer)->read;
}
// Write interface
__attribute__((always_inline)) static inline IoWrite *
protocolServerIoWrite(ProtocolServer *this)
{
ASSERT_INLINE(this != NULL);
return ((ProtocolServerPub *)this)->write;
return THIS_PUB(ProtocolServer)->write;
}
/***********************************************************************************************************************************

View File

@ -36,40 +36,35 @@ typedef struct StorageReadPub
__attribute__((always_inline)) static inline bool
storageReadIgnoreMissing(const StorageRead *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageReadPub *)this)->interface->ignoreMissing;
return THIS_PUB(StorageRead)->interface->ignoreMissing;
}
// Read interface
__attribute__((always_inline)) static inline IoRead *
storageReadIo(const StorageRead *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageReadPub *)this)->io;
return THIS_PUB(StorageRead)->io;
}
// Is there a read limit? NULL for no limit.
__attribute__((always_inline)) static inline const Variant *
storageReadLimit(const StorageRead *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageReadPub *)this)->interface->limit;
return THIS_PUB(StorageRead)->interface->limit;
}
// File name
__attribute__((always_inline)) static inline const String *
storageReadName(const StorageRead *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageReadPub *)this)->interface->name;
return THIS_PUB(StorageRead)->interface->name;
}
// Get file type
__attribute__((always_inline)) static inline const String *
storageReadType(const StorageRead *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageReadPub *)this)->interface->type;
return THIS_PUB(StorageRead)->interface->type;
}
/***********************************************************************************************************************************

View File

@ -253,16 +253,14 @@ Getters/Setters
__attribute__((always_inline)) static inline bool
storageFeature(const Storage *this, StorageFeature feature)
{
ASSERT_INLINE(this != NULL);
return ((const StoragePub *)this)->interface.feature >> feature & 1;
return THIS_PUB(Storage)->interface.feature >> feature & 1;
}
// Storage type (posix, cifs, etc.)
__attribute__((always_inline)) static inline const String *
storageType(const Storage *this)
{
ASSERT_INLINE(this != NULL);
return ((const StoragePub *)this)->type;
return THIS_PUB(Storage)->type;
}
/***********************************************************************************************************************************

View File

@ -293,16 +293,14 @@ typedef struct StoragePub
__attribute__((always_inline)) static inline void *
storageDriver(const Storage *this)
{
ASSERT_INLINE(this != NULL);
return ((const StoragePub *)this)->driver;
return THIS_PUB(Storage)->driver;
}
// Storage interface
__attribute__((always_inline)) static inline StorageInterface
storageInterface(const Storage *this)
{
ASSERT_INLINE(this != NULL);
return ((const StoragePub *)this)->interface;
return THIS_PUB(Storage)->interface;
}
/***********************************************************************************************************************************

View File

@ -40,72 +40,63 @@ typedef struct StorageWritePub
__attribute__((always_inline)) static inline bool
storageWriteAtomic(const StorageWrite *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageWritePub *)this)->interface->atomic;
return THIS_PUB(StorageWrite)->interface->atomic;
}
// Will the path be created if required?
__attribute__((always_inline)) static inline bool
storageWriteCreatePath(const StorageWrite *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageWritePub *)this)->interface->createPath;
return THIS_PUB(StorageWrite)->interface->createPath;
}
// Write interface
__attribute__((always_inline)) static inline IoWrite *
storageWriteIo(const StorageWrite *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageWritePub *)this)->io;
return THIS_PUB(StorageWrite)->io;
}
// File mode
__attribute__((always_inline)) static inline mode_t
storageWriteModeFile(const StorageWrite *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageWritePub *)this)->interface->modeFile;
return THIS_PUB(StorageWrite)->interface->modeFile;
}
// Path mode (if the destination path needs to be create)
__attribute__((always_inline)) static inline mode_t
storageWriteModePath(const StorageWrite *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageWritePub *)this)->interface->modePath;
return THIS_PUB(StorageWrite)->interface->modePath;
}
// File name
__attribute__((always_inline)) static inline const String *
storageWriteName(const StorageWrite *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageWritePub *)this)->interface->name;
return THIS_PUB(StorageWrite)->interface->name;
}
// Will the file be synced before it is closed?
__attribute__((always_inline)) static inline bool
storageWriteSyncFile(const StorageWrite *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageWritePub *)this)->interface->syncFile;
return THIS_PUB(StorageWrite)->interface->syncFile;
}
// Will the path be synced after the file is closed?
__attribute__((always_inline)) static inline bool
storageWriteSyncPath(const StorageWrite *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageWritePub *)this)->interface->syncPath;
return THIS_PUB(StorageWrite)->interface->syncPath;
}
// File type
__attribute__((always_inline)) static inline const String *
storageWriteType(const StorageWrite *this)
{
ASSERT_INLINE(this != NULL);
return ((const StorageWritePub *)this)->interface->type;
return THIS_PUB(StorageWrite)->interface->type;
}
/***********************************************************************************************************************************