mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 01:31:08 +00:00
Use inline functions rather than macros
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27863 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b96f176cbc
commit
aaca31acf2
1 changed files with 46 additions and 15 deletions
|
@ -55,39 +55,70 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/* Macros to make use of the pointer functions.
|
/* Wrapper functions to make use of the pointer functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Acquire the pointer value to store for the specified item.
|
/* Acquire the pointer value to store for the specified item.
|
||||||
*/
|
*/
|
||||||
#define GSPFAcquire(PF,Item) \
|
static inline void
|
||||||
(*(PF)->_acquireFunction)(Item, (PF)->_sizeFunction, (PF)->shouldCopyIn)
|
pointerFunctionsAcquire(NSConcretePointerFunctions *PF, void **dst, void *src)
|
||||||
|
{
|
||||||
|
if (PF->_acquireFunction != 0)
|
||||||
|
src = (*PF->_acquireFunction)(src, PF->_sizeFunction, PF->_shouldCopyIn);
|
||||||
|
#if GS_WITH_GC
|
||||||
|
if (PF->usesWeakReadAndWriteBarriers)
|
||||||
|
GSAssignZeroingWeakPointer(dst, src);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
*dst = src;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Generate an NSString description of the item
|
/* Generate an NSString description of the item
|
||||||
*/
|
*/
|
||||||
#define GSPFDescribe(PF,Item) (*(PF)->_acquireFunction)(Item)
|
static inline NSString *
|
||||||
|
pointerFunctionsDescribe(NSConcretePointerFunctions *PF, void *item)
|
||||||
|
{
|
||||||
|
if (PF->_descriptionFunction != 0)
|
||||||
|
return (*PF->_descriptionFunction)(item);
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Generate the hash of the item
|
/* Generate the hash of the item
|
||||||
*/
|
*/
|
||||||
#define GSPFHash(PF,Item) (*(PF)->_hashFunction)(Item, (PF)->_sizeFunction)
|
static inline NSUInteger
|
||||||
|
pointerFunctionsHash(NSConcretePointerFunctions *PF, void *item)
|
||||||
|
{
|
||||||
|
if (PF->_hashFunction != 0)
|
||||||
|
return (*PF->_hashFunction)(item, PF->_sizeFunction);
|
||||||
|
return (NSUInteger)item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Compare two items for equality
|
/* Compare two items for equality
|
||||||
*/
|
*/
|
||||||
#define GSPFIsEqual(PF,Item1, Item2) \
|
static inline BOOL
|
||||||
(*(PF)->_isEqualFunction)(Item1, Item2, (PF)->_sizeFunction)
|
pointerFunctionsEqual(NSConcretePointerFunctions *PF, void *item1, void *item2)
|
||||||
|
{
|
||||||
|
if (PF->_isEqualFunction != 0)
|
||||||
|
return (*PF->_isEqualFunction)(item1, item2, PF->_sizeFunction);
|
||||||
|
if (item1 == item2)
|
||||||
|
return YES;
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Relinquish the specified item and set it to zero.
|
/* Relinquish the specified item and set it to zero.
|
||||||
*/
|
*/
|
||||||
#define GSPFRelinquish(PF,Item) ({ \
|
static inline void
|
||||||
if ((PF)->_relinquishFunction != 0) \
|
pointerFunctionsRelinquish(NSConcretePointerFunctions *PF, void **itemptr)
|
||||||
(*(PF)->_relinquishFunction)(Item, (PF)->_sizeFunction); \
|
{
|
||||||
if ((PF)->usesWeakReadAndWriteBarriers) \
|
if (PF->_relinquishFunction != 0)
|
||||||
GSAssignZeroingWeakPointer((void**)&Item, (void*)0); \
|
(*PF->_relinquishFunction)(*itemptr, PF->_sizeFunction);
|
||||||
else \
|
if (PF->_usesWeakReadAndWriteBarriers)
|
||||||
Item = 0; \
|
GSAssignZeroingWeakPointer(itemptr, (void*)0);
|
||||||
})
|
else
|
||||||
|
*itemptr = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue