1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Use the method suffix only for methods in classes; use visitor or function for other kinds of functions.

New document guide.impl.c.naming sets out the rules for naming.

Copied from Perforce
 Change: 187159
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Gareth Rees 2014-10-07 23:48:55 +01:00
parent f3cf67c792
commit 00229b0479
27 changed files with 328 additions and 179 deletions

View file

@ -231,13 +231,13 @@ Count ABQDepth(ABQ abq)
}
/* ABQIterate -- call 'iterate' for each element in an ABQ */
void ABQIterate(ABQ abq, ABQIterateMethod iterate, void *closureP, Size closureS)
/* ABQIterate -- call 'visitor' for each element in an ABQ */
void ABQIterate(ABQ abq, ABQVisitor visitor, void *closureP, Size closureS)
{
Index copy, index, in;
AVERT(ABQ, abq);
AVER(FUNCHECK(iterate));
AVER(FUNCHECK(visitor));
copy = abq->out;
index = abq->out;
@ -247,7 +247,7 @@ void ABQIterate(ABQ abq, ABQIterateMethod iterate, void *closureP, Size closureS
void *element = ABQElement(abq, index);
Bool delete = FALSE;
Bool cont;
cont = (*iterate)(&delete, element, closureP, closureS);
cont = (*visitor)(&delete, element, closureP, closureS);
AVERT(Bool, cont);
AVERT(Bool, delete);
if (!delete) {

View file

@ -1,7 +1,7 @@
/* abq.h: QUEUE INTERFACE
*
* $Id$
* Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
* Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license.
*
* .purpose: A fixed-length FIFO queue.
*
@ -24,7 +24,7 @@
typedef struct ABQStruct *ABQ;
typedef Res (*ABQDescribeElement)(void *element, mps_lib_FILE *stream, Count depth);
typedef Bool (*ABQIterateMethod)(Bool *deleteReturn, void *element, void *closureP, Size closureS);
typedef Bool (*ABQVisitor)(Bool *deleteReturn, void *element, void *closureP, Size closureS);
extern Res ABQInit(Arena arena, ABQ abq, void *owner, Count elements, Size elementSize);
extern Bool ABQCheck(ABQ abq);
@ -36,7 +36,7 @@ extern Res ABQDescribe(ABQ abq, ABQDescribeElement describeElement, mps_lib_FILE
extern Bool ABQIsEmpty(ABQ abq);
extern Bool ABQIsFull(ABQ abq);
extern Count ABQDepth(ABQ abq);
extern void ABQIterate(ABQ abq, ABQIterateMethod iterate, void *closureP, Size closureS);
extern void ABQIterate(ABQ abq, ABQVisitor visitor, void *closureP, Size closureS);
/* Types */
@ -63,7 +63,7 @@ typedef struct ABQStruct
/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
* Copyright (C) 2001-2014 Ravenbrook Limited <http://www.ravenbrook.com/>.
* All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options.
*

View file

@ -215,7 +215,7 @@ static void cbsUpdateZonedNode(SplayTree splay, Tree tree)
ARG_DEFINE_KEY(cbs_block_pool, Pool);
static Res cbsInitComm(Land land, ArgList args, SplayUpdateNodeMethod update,
static Res cbsInitComm(Land land, ArgList args, SplayUpdateNodeFunction update,
Size blockStructSize)
{
CBS cbs;
@ -1058,7 +1058,7 @@ static Res cbsFindInZones(Bool *foundReturn, Range rangeReturn,
cbsTestNodeInZonesClosureStruct closure;
Res res;
LandFindMethod landFind;
SplayFindMethod splayFind;
SplayFindFunction splayFind;
RangeStruct rangeStruct, oldRangeStruct;
AVER(foundReturn != NULL);

View file

@ -132,7 +132,7 @@ static Res DebugPoolInit(Pool pool, ArgList args)
Res res;
PoolDebugOptions options = &debugPoolOptionsDefault;
PoolDebugMixin debug;
TagInitMethod tagInit;
TagInitFunction tagInit;
Size tagSize;
ArgStruct arg;
@ -648,19 +648,16 @@ static void DebugPoolFree(Pool pool, Addr old, Size size)
/* TagWalk -- walk all objects in the pool using tags */
typedef void (*ObjectsStepMethod)(Addr addr, Size size, Format fmt,
Pool pool, void *tagData, void *p);
typedef void (*ObjectsVisitor)(Addr addr, Size size, Format fmt,
Pool pool, void *tagData, void *p);
#define ObjectsStepMethodCheck(f) \
((f) != NULL) /* that's the best we can do */
static void TagWalk(Pool pool, ObjectsStepMethod step, void *p)
static void TagWalk(Pool pool, ObjectsVisitor visitor, void *p)
{
Tree node;
PoolDebugMixin debug;
AVERT(Pool, pool);
AVERT(ObjectsStepMethod, step);
AVER(FUNCHECK(visitor));
/* Can't check p */
debug = DebugPoolDebugMixin(pool);
@ -671,7 +668,7 @@ static void TagWalk(Pool pool, ObjectsStepMethod step, void *p)
while (node != TreeEMPTY) {
Tag tag = TagOfTree(node);
step(tag->addr, tag->size, NULL, pool, &tag->userdata, p);
(*visitor)(tag->addr, tag->size, NULL, pool, &tag->userdata, p);
node = SplayTreeNext(&debug->index, &tag->addr);
}
}

View file

@ -3,7 +3,7 @@
* See <design/object-debug>.
*
* $Id$
* Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
* Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license.
* Portions copyright (C) 2002 Global Graphics Software.
*/
@ -15,9 +15,9 @@
#include <stdarg.h>
/* tag init methods: copying the user-supplied data into the tag */
/* tag init function: copies the user-supplied data into the tag */
typedef void (*TagInitMethod)(void* tag, va_list args);
typedef void (*TagInitFunction)(void *tag, va_list args);
/* PoolDebugOptions -- option structure for debug pool init
@ -30,7 +30,7 @@ typedef struct PoolDebugOptionsStruct {
Size fenceSize;
const void *freeTemplate;
Size freeSize;
/* TagInitMethod tagInit; */
/* TagInitFunction tagInit; */
/* Size tagSize; */
} PoolDebugOptionsStruct;
@ -47,7 +47,7 @@ typedef struct PoolDebugMixinStruct {
Size fenceSize;
const struct AddrStruct *freeTemplate;
Size freeSize;
TagInitMethod tagInit;
TagInitFunction tagInit;
Size tagSize;
Pool tagPool;
Count missingTags;
@ -73,7 +73,7 @@ extern void DebugPoolFreeCheck(Pool pool, Addr base, Addr limit);
/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
* Copyright (C) 2001-2014 Ravenbrook Limited <http://www.ravenbrook.com/>.
* All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options.
*

View file

@ -222,9 +222,9 @@ extern Res PoolFixEmergency(Pool pool, ScanState ss, Seg seg, Addr *refIO);
extern void PoolReclaim(Pool pool, Trace trace, Seg seg);
extern void PoolTraceEnd(Pool pool, Trace trace);
extern Res PoolAddrObject(Addr *pReturn, Pool pool, Seg seg, Addr addr);
extern void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
extern void PoolWalk(Pool pool, Seg seg, FormattedObjectsVisitor f,
void *v, size_t s);
extern void PoolFreeWalk(Pool pool, FreeBlockStepMethod f, void *p);
extern void PoolFreeWalk(Pool pool, FreeBlockVisitor f, void *p);
extern Size PoolTotalSize(Pool pool);
extern Size PoolFreeSize(Pool pool);
@ -276,9 +276,9 @@ extern Res PoolTrivFramePop(Pool pool, Buffer buf, AllocFrame frame);
extern void PoolNoFramePopPending(Pool pool, Buffer buf, AllocFrame frame);
extern void PoolTrivFramePopPending(Pool pool, Buffer buf, AllocFrame frame);
extern Res PoolNoAddrObject(Addr *pReturn, Pool pool, Seg seg, Addr addr);
extern void PoolNoWalk(Pool pool, Seg seg, FormattedObjectsStepMethod step,
extern void PoolNoWalk(Pool pool, Seg seg, FormattedObjectsVisitor f,
void *p, size_t s);
extern void PoolTrivFreeWalk(Pool pool, FreeBlockStepMethod f, void *p);
extern void PoolTrivFreeWalk(Pool pool, FreeBlockVisitor f, void *p);
extern PoolDebugMixin PoolNoDebugMixin(Pool pool);
extern BufferClass PoolNoBufferClass(void);
extern Size PoolNoSize(Pool pool);

View file

@ -148,11 +148,11 @@ typedef Res (*TraceFixMethod)(ScanState ss, Ref *refIO);
/* Heap Walker */
/* This type is used by the PoolClass method Walk */
typedef void (*FormattedObjectsStepMethod)(Addr obj, Format fmt, Pool pool,
typedef void (*FormattedObjectsVisitor)(Addr obj, Format fmt, Pool pool,
void *v, size_t s);
/* This type is used by the PoolClass method Walk */
typedef void (*FreeBlockStepMethod)(Addr base, Addr limit, Pool pool, void *p);
typedef void (*FreeBlockVisitor)(Addr base, Addr limit, Pool pool, void *p);
/* Seg*Method -- see <design/seg/> */
@ -230,10 +230,9 @@ typedef void (*PoolFramePopPendingMethod)(Pool pool, Buffer buf,
AllocFrame frame);
typedef Res (*PoolAddrObjectMethod)(Addr *pReturn,
Pool pool, Seg seg, Addr addr);
typedef void (*PoolWalkMethod)(Pool pool, Seg seg,
FormattedObjectsStepMethod f,
typedef void (*PoolWalkMethod)(Pool pool, Seg seg, FormattedObjectsVisitor f,
void *v, size_t s);
typedef void (*PoolFreeWalkMethod)(Pool pool, FreeBlockStepMethod f, void *p);
typedef void (*PoolFreeWalkMethod)(Pool pool, FreeBlockVisitor f, void *p);
typedef BufferClass (*PoolBufferClassMethod)(void);
typedef Res (*PoolDescribeMethod)(Pool pool, mps_lib_FILE *stream, Count depth);
typedef PoolDebugMixin (*PoolDebugMixinMethod)(Pool pool);

View file

@ -495,8 +495,7 @@ Res PoolAddrObject(Addr *pReturn, Pool pool, Seg seg, Addr addr)
/* PoolWalk -- walk objects in this segment */
void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
void *p, size_t s)
void PoolWalk(Pool pool, Seg seg, FormattedObjectsVisitor f, void *p, size_t s)
{
AVERT(Pool, pool);
AVERT(Seg, seg);
@ -512,7 +511,7 @@ void PoolWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
* PoolFreeWalk is not required to find all free blocks.
*/
void PoolFreeWalk(Pool pool, FreeBlockStepMethod f, void *p)
void PoolFreeWalk(Pool pool, FreeBlockVisitor f, void *p)
{
AVERT(Pool, pool);
AVER(FUNCHECK(f));

View file

@ -648,8 +648,8 @@ Res PoolNoAddrObject(Addr *pReturn, Pool pool, Seg seg, Addr addr)
return ResUNIMPL;
}
void PoolNoWalk(Pool pool, Seg seg,
FormattedObjectsStepMethod f, void *p, size_t s)
void PoolNoWalk(Pool pool, Seg seg, FormattedObjectsVisitor f,
void *p, size_t s)
{
AVERT(Pool, pool);
AVERT(Seg, seg);
@ -662,7 +662,7 @@ void PoolNoWalk(Pool pool, Seg seg,
}
void PoolTrivFreeWalk(Pool pool, FreeBlockStepMethod f, void *p)
void PoolTrivFreeWalk(Pool pool, FreeBlockVisitor f, void *p)
{
AVERT(Pool, pool);
AVER(FUNCHECK(f));

View file

@ -22,7 +22,7 @@ typedef struct AMCStruct *AMC;
typedef struct amcGenStruct *amcGen;
/* Function returning TRUE if block in nailboarded segment is pinned. */
typedef Bool (*amcPinnedMethod)(AMC amc, Nailboard board, Addr base, Addr limit);
typedef Bool (*amcPinnedFunction)(AMC amc, Nailboard board, Addr base, Addr limit);
/* forward declarations */
@ -471,7 +471,7 @@ typedef struct AMCStruct { /* <design/poolamc/#struct> */
amcGen afterRampGen; /* the generation after rampGen */
unsigned rampCount; /* <design/poolamc/#ramp.count> */
int rampMode; /* <design/poolamc/#ramp.mode> */
amcPinnedMethod pinned; /* function determining if block is pinned */
amcPinnedFunction pinned; /* function determining if block is pinned */
Size extendBy; /* segment size to extend pool by */
Size largeSize; /* min size of "large" segments */
@ -2168,7 +2168,7 @@ static void AMCTraceEnd(Pool pool, Trace trace)
/* AMCWalk -- Apply function to (black) objects in segment */
static void AMCWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
static void AMCWalk(Pool pool, Seg seg, FormattedObjectsVisitor f,
void *p, size_t s)
{
Addr object, nextObject, limit;
@ -2218,8 +2218,7 @@ static void AMCWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
/* amcWalkAll -- Apply a function to all (black) objects in a pool */
static void amcWalkAll(Pool pool, FormattedObjectsStepMethod f,
void *p, size_t s)
static void amcWalkAll(Pool pool, FormattedObjectsVisitor f, void *p, size_t s)
{
Arena arena;
Ring ring, next, node;

View file

@ -85,7 +85,7 @@ Bool AMSSegCheck(AMSSeg amsseg)
/* AMSSegFreeWalk -- walk the free space in a segment */
void AMSSegFreeWalk(AMSSeg amsseg, FreeBlockStepMethod f, void *p)
void AMSSegFreeWalk(AMSSeg amsseg, FreeBlockVisitor f, void *p)
{
Pool pool;
Seg seg;
@ -1653,7 +1653,7 @@ static void AMSReclaim(Pool pool, Trace trace, Seg seg)
/* AMSFreeWalk -- free block walking method of the pool class */
static void AMSFreeWalk(Pool pool, FreeBlockStepMethod f, void *p)
static void AMSFreeWalk(Pool pool, FreeBlockVisitor f, void *p)
{
AMS ams;
Ring node, ring, nextNode; /* for iterating over the segments */

View file

@ -1,7 +1,7 @@
/* poolams.h: AUTOMATIC MARK & SWEEP POOL CLASS INTERFACE
*
* $Id$
* Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
* Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license.
* Portions copyright (C) 2002 Global Graphics Software.
*
* .purpose: Internal interface to AMS functionality. */
@ -175,7 +175,7 @@ extern Res AMSScan(Bool *totalReturn, ScanState ss, Pool pool, Seg seg);
#define AMSChain(ams) ((ams)->chain)
extern void AMSSegFreeWalk(AMSSeg amsseg, FreeBlockStepMethod f, void *p);
extern void AMSSegFreeWalk(AMSSeg amsseg, FreeBlockVisitor f, void *p);
extern void AMSSegFreeCheck(AMSSeg amsseg);
@ -198,7 +198,7 @@ extern AMSPoolClass AMSDebugPoolClassGet(void);
/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
* Copyright (C) 2001-2014 Ravenbrook Limited <http://www.ravenbrook.com/>.
* All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options.
*

View file

@ -74,7 +74,7 @@ typedef struct awlStatTotalStruct {
/* the type of a function to find an object's dependent object */
typedef Addr (*FindDependentMethod)(Addr object);
typedef Addr (*FindDependentFunction)(Addr object);
/* AWLStruct -- AWL pool structure
*
@ -86,7 +86,7 @@ typedef struct AWLStruct {
Shift alignShift;
PoolGenStruct pgen; /* generation representing the pool */
Count succAccesses; /* number of successive single accesses */
FindDependentMethod findDependent; /* to find a dependent object */
FindDependentFunction findDependent; /* to find a dependent object */
awlStatTotalStruct stats;
Sig sig;
} AWLStruct, *AWL;
@ -550,7 +550,7 @@ static Res AWLInit(Pool pool, ArgList args)
{
AWL awl;
Format format;
FindDependentMethod findDependent = awlNoDependent;
FindDependentFunction findDependent = awlNoDependent;
Chain chain;
Res res;
ArgStruct arg;
@ -564,7 +564,7 @@ static Res AWLInit(Pool pool, ArgList args)
ArgRequire(&arg, args, MPS_KEY_FORMAT);
format = arg.val.format;
if (ArgPick(&arg, args, MPS_KEY_AWL_FIND_DEPENDENT))
findDependent = (FindDependentMethod)arg.val.addr_method;
findDependent = (FindDependentFunction)arg.val.addr_method;
if (ArgPick(&arg, args, MPS_KEY_CHAIN))
chain = arg.val.chain;
else {
@ -1232,7 +1232,7 @@ static Res AWLAccess(Pool pool, Seg seg, Addr addr,
/* AWLWalk -- walk all objects */
static void AWLWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
static void AWLWalk(Pool pool, Seg seg, FormattedObjectsVisitor f,
void *p, size_t s)
{
AWL awl;

View file

@ -401,8 +401,7 @@ static void loSegReclaim(LOSeg loseg, Trace trace)
/* This walks over _all_ objects in the heap, whether they are */
/* black or white, they are still validly formatted as this is */
/* a leaf pool, so there can't be any dangling references */
static void LOWalk(Pool pool, Seg seg,
FormattedObjectsStepMethod f,
static void LOWalk(Pool pool, Seg seg, FormattedObjectsVisitor f,
void *p, size_t s)
{
Addr base;

View file

@ -624,7 +624,7 @@ static void SNCFramePopPending(Pool pool, Buffer buf, AllocFrame frame)
}
static void SNCWalk(Pool pool, Seg seg, FormattedObjectsStepMethod f,
static void SNCWalk(Pool pool, Seg seg, FormattedObjectsVisitor f,
void *p, size_t s)
{
AVERT(Pool, pool);

View file

@ -68,9 +68,9 @@ Bool SplayTreeCheck(SplayTree splay)
*/
void SplayTreeInit(SplayTree splay,
TreeCompare compare,
TreeKeyMethod nodeKey,
SplayUpdateNodeMethod updateNode)
TreeCompareFunction compare,
TreeKeyFunction nodeKey,
SplayUpdateNodeFunction updateNode)
{
AVER(splay != NULL);
AVER(FUNCHECK(compare));
@ -298,7 +298,8 @@ typedef struct SplayStateStruct {
*/
static Compare SplaySplitDown(SplayStateStruct *stateReturn,
SplayTree splay, TreeKey key, TreeCompare compare)
SplayTree splay, TreeKey key,
TreeCompareFunction compare)
{
TreeStruct sentinel;
Tree middle, leftLast, rightFirst, leftPrev, rightNext;
@ -503,7 +504,8 @@ static Tree SplayZagZagRev(Tree middle, Tree *leftLastIO)
*/
static Compare SplaySplitRev(SplayStateStruct *stateReturn,
SplayTree splay, TreeKey key, TreeCompare compare)
SplayTree splay, TreeKey key,
TreeCompareFunction compare)
{
Tree middle, leftLast, rightFirst;
Compare cmp;
@ -650,7 +652,8 @@ static void SplayAssembleRev(SplayTree splay, SplayState state)
/* SplaySplit -- call SplaySplitDown or SplaySplitRev as appropriate */
static Compare SplaySplit(SplayStateStruct *stateReturn,
SplayTree splay, TreeKey key, TreeCompare compare)
SplayTree splay, TreeKey key,
TreeCompareFunction compare)
{
if (SplayHasUpdate(splay))
return SplaySplitRev(stateReturn, splay, key, compare);
@ -688,7 +691,8 @@ static void SplayAssemble(SplayTree splay, SplayState state)
* See <design/splay/#impl.splay>.
*/
static Compare SplaySplay(SplayTree splay, TreeKey key, TreeCompare compare)
static Compare SplaySplay(SplayTree splay, TreeKey key,
TreeCompareFunction compare)
{
Compare cmp;
SplayStateStruct stateStruct;
@ -1020,7 +1024,7 @@ Tree SplayTreeNext(SplayTree splay, TreeKey oldKey) {
*/
static Res SplayNodeDescribe(Tree node, mps_lib_FILE *stream,
TreeDescribeMethod nodeDescribe)
TreeDescribeFunction nodeDescribe)
{
Res res;
@ -1083,8 +1087,8 @@ static Res SplayNodeDescribe(Tree node, mps_lib_FILE *stream,
*/
typedef struct SplayFindClosureStruct {
SplayTestNodeMethod testNode;
SplayTestTreeMethod testTree;
SplayTestNodeFunction testNode;
SplayTestTreeFunction testTree;
void *p;
Size s;
SplayTree splay;
@ -1096,8 +1100,8 @@ static Compare SplayFindFirstCompare(Tree node, TreeKey key)
SplayFindClosure closure;
void *closureP;
Size closureS;
SplayTestNodeMethod testNode;
SplayTestTreeMethod testTree;
SplayTestNodeFunction testNode;
SplayTestTreeFunction testTree;
SplayTree splay;
AVERT(Tree, node);
@ -1137,8 +1141,8 @@ static Compare SplayFindLastCompare(Tree node, TreeKey key)
SplayFindClosure closure;
void *closureP;
Size closureS;
SplayTestNodeMethod testNode;
SplayTestTreeMethod testTree;
SplayTestNodeFunction testNode;
SplayTestTreeFunction testTree;
SplayTree splay;
AVERT(Tree, node);
@ -1190,8 +1194,8 @@ static Compare SplayFindLastCompare(Tree node, TreeKey key)
*/
Bool SplayFindFirst(Tree *nodeReturn, SplayTree splay,
SplayTestNodeMethod testNode,
SplayTestTreeMethod testTree,
SplayTestNodeFunction testNode,
SplayTestTreeFunction testTree,
void *closureP, Size closureS)
{
SplayFindClosureStruct closureStruct;
@ -1254,8 +1258,8 @@ Bool SplayFindFirst(Tree *nodeReturn, SplayTree splay,
/* SplayFindLast -- As SplayFindFirst but in reverse address order */
Bool SplayFindLast(Tree *nodeReturn, SplayTree splay,
SplayTestNodeMethod testNode,
SplayTestTreeMethod testTree,
SplayTestNodeFunction testNode,
SplayTestTreeFunction testTree,
void *closureP, Size closureS)
{
SplayFindClosureStruct closureStruct;
@ -1362,7 +1366,7 @@ void SplayNodeInit(SplayTree splay, Tree node)
*/
Res SplayTreeDescribe(SplayTree splay, mps_lib_FILE *stream, Count depth,
TreeDescribeMethod nodeDescribe)
TreeDescribeFunction nodeDescribe)
{
Res res;

View file

@ -1,7 +1,7 @@
/* splay.h: SPLAY TREE HEADER
*
* $Id$
* Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
* Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license.
*
* .source: <design/splay/>
*/
@ -15,21 +15,21 @@
typedef struct SplayTreeStruct *SplayTree;
typedef Bool (*SplayTestNodeMethod)(SplayTree splay, Tree node,
void *closureP, Size closureS);
typedef Bool (*SplayTestTreeMethod)(SplayTree splay, Tree node,
void *closureP, Size closureS);
typedef Bool (*SplayTestNodeFunction)(SplayTree splay, Tree node,
void *closureP, Size closureS);
typedef Bool (*SplayTestTreeFunction)(SplayTree splay, Tree node,
void *closureP, Size closureS);
typedef void (*SplayUpdateNodeMethod)(SplayTree splay, Tree node);
typedef void (*SplayUpdateNodeFunction)(SplayTree splay, Tree node);
extern void SplayTrivUpdate(SplayTree splay, Tree node);
#define SplayTreeSig ((Sig)0x5195B1A1) /* SIGnature SPLAY */
typedef struct SplayTreeStruct {
Sig sig;
TreeCompare compare;
TreeKeyMethod nodeKey;
SplayUpdateNodeMethod updateNode;
TreeCompareFunction compare;
TreeKeyFunction nodeKey;
SplayUpdateNodeFunction updateNode;
Tree root;
} SplayTreeStruct;
@ -38,9 +38,9 @@ typedef struct SplayTreeStruct {
extern Bool SplayTreeCheck(SplayTree splay);
extern void SplayTreeInit(SplayTree splay,
TreeCompare compare,
TreeKeyMethod nodeKey,
SplayUpdateNodeMethod updateNode);
TreeCompareFunction compare,
TreeKeyFunction nodeKey,
SplayUpdateNodeFunction updateNode);
extern void SplayTreeFinish(SplayTree splay);
extern Bool SplayTreeInsert(SplayTree splay, Tree node);
@ -55,24 +55,24 @@ extern Bool SplayTreeNeighbours(Tree *leftReturn,
extern Tree SplayTreeFirst(SplayTree splay);
extern Tree SplayTreeNext(SplayTree splay, TreeKey oldKey);
typedef Bool (*SplayFindMethod)(Tree *nodeReturn, SplayTree splay,
SplayTestNodeMethod testNode,
SplayTestTreeMethod testTree,
void *closureP, Size closureS);
typedef Bool (*SplayFindFunction)(Tree *nodeReturn, SplayTree splay,
SplayTestNodeFunction testNode,
SplayTestTreeFunction testTree,
void *closureP, Size closureS);
extern Bool SplayFindFirst(Tree *nodeReturn, SplayTree splay,
SplayTestNodeMethod testNode,
SplayTestTreeMethod testTree,
SplayTestNodeFunction testNode,
SplayTestTreeFunction testTree,
void *closureP, Size closureS);
extern Bool SplayFindLast(Tree *nodeReturn, SplayTree splay,
SplayTestNodeMethod testNode,
SplayTestTreeMethod testTree,
SplayTestNodeFunction testNode,
SplayTestTreeFunction testTree,
void *closureP, Size closureS);
extern void SplayNodeRefresh(SplayTree splay, Tree node);
extern void SplayNodeInit(SplayTree splay, Tree node);
extern Res SplayTreeDescribe(SplayTree splay, mps_lib_FILE *stream,
Count depth, TreeDescribeMethod nodeDescribe);
Count depth, TreeDescribeFunction nodeDescribe);
extern void SplayDebugUpdate(SplayTree splay, Tree tree);
extern Count SplayDebugCount(SplayTree splay);
@ -83,7 +83,7 @@ extern Count SplayDebugCount(SplayTree splay);
/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
* Copyright (C) 2001-2014 Ravenbrook Limited <http://www.ravenbrook.com/>.
* All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options.
*

View file

@ -222,8 +222,8 @@ Res TableGrow(Table table, Count extraCapacity)
extern Res TableCreate(Table *tableReturn,
Count length,
TableAllocMethod tableAlloc,
TableFreeMethod tableFree,
TableAllocFunction tableAlloc,
TableFreeFunction tableFree,
void *allocClosure,
Word unusedKey,
Word deletedKey)

View file

@ -1,5 +1,5 @@
/* table.h: Interface for a dictionary
* Copyright (c) 2001 Ravenbrook Limited. See end of file for license.
* Copyright (c) 2001-2014 Ravenbrook Limited. See end of file for license.
*
* $Id$
*/
@ -15,8 +15,8 @@ typedef struct TableStruct *Table;
#define TableSig ((Sig)0x5192AB13) /* SIGnature TABLE */
typedef void *(*TableAllocMethod)(void *closure, size_t size);
typedef void (*TableFreeMethod)(void *closure, void *p, size_t size);
typedef void *(*TableAllocFunction)(void *closure, size_t size);
typedef void (*TableFreeFunction)(void *closure, void *p, size_t size);
typedef struct TableEntryStruct {
Word key;
@ -28,8 +28,8 @@ typedef struct TableStruct {
Count length; /* Number of slots in the array */
Count count; /* Active entries in the table */
TableEntry array; /* Array of table slots */
TableAllocMethod alloc;
TableFreeMethod free;
TableAllocFunction alloc;
TableFreeFunction free;
void *allocClosure;
Word unusedKey; /* key marking unused (undefined) entries */
Word deletedKey; /* key marking deleted entries */
@ -37,8 +37,8 @@ typedef struct TableStruct {
extern Res TableCreate(Table *tableReturn,
Count length,
TableAllocMethod tableAlloc,
TableFreeMethod tableFree,
TableAllocFunction tableAlloc,
TableFreeFunction tableFree,
void *allocClosure,
Word unusedKey,
Word deletedKey);
@ -60,7 +60,7 @@ extern Res TableGrow(Table table, Count extraCapacity);
/* C. COPYRIGHT AND LICENSE
*
* Copyright (C) 2001-2002 Ravenbrook Limited <http://www.ravenbrook.com/>.
* Copyright (C) 2001-2014 Ravenbrook Limited <http://www.ravenbrook.com/>.
* All rights reserved. This is an open source license. Contact
* Ravenbrook for commercial licensing options.
*

View file

@ -50,7 +50,8 @@ Bool TreeCheckLeaf(Tree tree)
*/
static Count TreeDebugCountBetween(Tree node,
TreeCompare compare, TreeKeyMethod key,
TreeCompareFunction compare,
TreeKeyFunction key,
TreeKey min, TreeKey max)
{
if (node == TreeEMPTY)
@ -63,7 +64,8 @@ static Count TreeDebugCountBetween(Tree node,
TreeDebugCountBetween(TreeRight(node), compare, key, key(node), max);
}
Count TreeDebugCount(Tree tree, TreeCompare compare, TreeKeyMethod key)
Count TreeDebugCount(Tree tree, TreeCompareFunction compare,
TreeKeyFunction key)
{
AVERT(Tree, tree);
return TreeDebugCountBetween(tree, compare, key, NULL, NULL);
@ -80,7 +82,8 @@ Count TreeDebugCount(Tree tree, TreeCompare compare, TreeKeyMethod key)
* or CompareGREATER for its right.
*/
Compare TreeFind(Tree *treeReturn, Tree root, TreeKey key, TreeCompare compare)
Compare TreeFind(Tree *treeReturn, Tree root, TreeKey key,
TreeCompareFunction compare)
{
Tree node, parent;
Compare cmp = CompareEQUAL;
@ -126,7 +129,8 @@ Compare TreeFind(Tree *treeReturn, Tree root, TreeKey key, TreeCompare compare)
* *treeReturn unchanged and return FALSE.
*/
Bool TreeFindNext(Tree *treeReturn, Tree root, TreeKey key, TreeCompare compare)
Bool TreeFindNext(Tree *treeReturn, Tree root, TreeKey key,
TreeCompareFunction compare)
{
Tree node, best = NULL;
Bool result = FALSE;
@ -169,7 +173,7 @@ Bool TreeFindNext(Tree *treeReturn, Tree root, TreeKey key, TreeCompare compare)
*/
Bool TreeInsert(Tree *treeReturn, Tree root, Tree node,
TreeKey key, TreeCompare compare)
TreeKey key, TreeCompareFunction compare)
{
Tree parent;
Compare cmp;
@ -318,8 +322,8 @@ static Tree stepUpLeft(Tree node, Tree *parentIO)
}
Bool TreeTraverse(Tree tree,
TreeCompare compare,
TreeKeyMethod key,
TreeCompareFunction compare,
TreeKeyFunction key,
TreeVisitor visit, void *closureP, Size closureS)
{
Tree parent, node;

View file

@ -25,21 +25,21 @@ typedef struct TreeStruct {
Tree left, right;
} TreeStruct;
typedef Res (*TreeDescribeMethod)(Tree tree, mps_lib_FILE *stream);
typedef Res (*TreeDescribeFunction)(Tree tree, mps_lib_FILE *stream);
/* TreeKey and TreeCompare -- ordered binary trees
/* TreeKeyFunction and TreeCompareFunction -- ordered binary trees
*
* Binary trees are almost always ordered, and these types provide the
* abstraction for ordering. A TreeCompare method returns whether a key
* is less than, equal to, or greater than the key in a tree node. A
* TreeKeyMethod extracts a key from a node, depending on how TreeStruct
* is embedded within its parent structure.
* abstraction for ordering. A TreeCompareFunction method returns
* whether a key is less than, equal to, or greater than the key in a
* tree node. A TreeKeyFunction extracts a key from a node, depending
* on how TreeStruct is embedded within its parent structure.
*/
typedef void *TreeKey;
typedef Compare (*TreeCompare)(Tree tree, TreeKey key);
typedef TreeKey (*TreeKeyMethod)(Tree tree);
typedef Compare (*TreeCompareFunction)(Tree tree, TreeKey key);
typedef TreeKey (*TreeKeyFunction)(Tree tree);
/* When storing Addrs in a tree, it is fastest to cast the Addr
@ -67,7 +67,8 @@ typedef TreeKey (*TreeKeyMethod)(Tree tree);
extern Bool TreeCheck(Tree tree);
extern Bool TreeCheckLeaf(Tree tree);
extern Count TreeDebugCount(Tree tree, TreeCompare compare, TreeKeyMethod key);
extern Count TreeDebugCount(Tree tree, TreeCompareFunction compare,
TreeKeyFunction key);
#define TreeInit(tree) \
BEGIN \
@ -115,17 +116,17 @@ extern Count TreeDebugCount(Tree tree, TreeCompare compare, TreeKeyMethod key);
#define TreeHasRight(tree) (TreeRight(tree) != TreeEMPTY)
extern Compare TreeFind(Tree *treeReturn, Tree root,
TreeKey key, TreeCompare compare);
TreeKey key, TreeCompareFunction compare);
extern Bool TreeFindNext(Tree *treeReturn, Tree root,
TreeKey key, TreeCompare compare);
TreeKey key, TreeCompareFunction compare);
extern Bool TreeInsert(Tree *treeReturn, Tree root, Tree node,
TreeKey key, TreeCompare compare);
TreeKey key, TreeCompareFunction compare);
typedef Bool TreeVisitor(Tree tree, void *closureP, Size closureS);
extern Bool TreeTraverse(Tree tree,
TreeCompare compare,
TreeKeyMethod key,
TreeCompareFunction compare,
TreeKeyFunction key,
TreeVisitor visit, void *closureP, Size closureS);
extern Bool TreeTraverseMorris(Tree tree, TreeVisitor visit,
void *closureP, Size closureS);

View file

@ -56,7 +56,7 @@ static void ArenaFormattedObjectsStep(Addr object, Format format, Pool pool,
*
* So called because it walks all formatted objects in an arena. */
static void ArenaFormattedObjectsWalk(Arena arena, FormattedObjectsStepMethod f,
static void ArenaFormattedObjectsWalk(Arena arena, FormattedObjectsVisitor f,
void *p, size_t s)
{
Seg seg;

View file

@ -92,7 +92,7 @@ If the queue is full, return ``TRUE``, otherwise return ``FALSE``.
Return the number of elements in the queue.
``typedef Bool (*ABQIterateMethod)(Bool *deleteReturn, void *element, void *closureP, Size closureS)``
``typedef Bool (*ABQVisitor)(Bool *deleteReturn, void *element, void *closureP, Size closureS)``
A callback function for ``ABQIterate()``. The parameter ``element`` is
an element in the queue, and ``closureP`` and ``closureS`` are the
@ -102,10 +102,10 @@ the queue, or ``TRUE`` if ``element`` must be deleted from the queue.
It must return ``TRUE`` if the iteration must continue, or ``FALSE``
if the iteration must stop after processing ``element``.
``void ABQIterate(ABQ abq, ABQIterateMethod iterate, void *closureP, Size closureS)``
``void ABQIterate(ABQ abq, ABQVisitor visitor, void *closureP, Size closureS)``
Call ``iterate`` for each elements in the queue, passing the element
and ``closureP``. See ``ABQIterateMethod`` for details.
Call ``visitor`` for each element in the queue, passing the element
and ``closureP``. See ``ABQVisitor`` for details.
Document History

View file

@ -0,0 +1,144 @@
.. mode: -*- rst -*-
C Style -- naming
=================
:Tag: guide.impl.c.naming
:Author: Gareth Rees
:Date: 2014-10-07
:Status: incomplete guide
:Format: rst
:Revision: $Id$
:Copyright: See `Copyright and License`_.
:Index terms:
pair: C language; naming guide
pair: C language naming; guide
Introduction
------------
_`.scope`: This document describes the conventions for naming in C
source code that's internal in the MPS. See `design.mps.interface-c`_
for the corresponding conventions for the public interface.
.. _design.mps.interface-c: interface-c
_`.readership`: This document is intended for anyone working on or
with the C source code.
Capitalization
--------------
_`.capital.macro`: Statement-like macros have names consisting of
uppercase words separated by underscores, for example
``ARG_DEFINE_KEY``.
_`.capital.constant`: Constants have names consisting of a type (named
according to `.capital.program`_ or `.capital.other`_), concatenated
with an identifier in uppercase with underscores, for example
``BufferFramePOP_PENDING``.
_`.capital.program`: Other names with program scope consist of
concatenated title-case words, for example ``BufferFramePush``.
_`.capital.other`: Other names (including function parameters, names
with block scope, and names with file scope) consist of concatenated
words, the first of which is lowercase and the remainder are
uppercase. For example, ``poolReturn``.
Prefixes
--------
_`.prefix.program`: Any name with program scope must start with the
name of the module to which it belongs. For example, names belonging
to the buffer module must start with ``buffer`` or ``Buffer`` or
``BUFFER``. Justification: the C language lacks a namespace facility
so the only way to avoid name clashes is for each name to be globally
unique.
_`.prefix.file`: Any name with file scope should start with the name
of the module to which it belongs. Justification: makes it easy to
tell which module a function belongs to; makes it easy to set
breakpoints in the debugger.
Suffixes
--------
_`.suffix.struct`: The type of a structure must be the same as the
structure tag, and must consist of the type of the pointer to the
structure concatenated with ``Struct``. For example, ``ArenaStruct``.
_`.suffix.union`: The type of a structure must be the same as the
structure tag, and must consist of the type of the pointer to the
structure concatenated with ``Union``. For example, ``PageUnion``.
_`.suffix.class`: The type of a class (see `design.mps.protocol`_)
must end with ``Class``. For example, ``ArenaClass``.
.. _design.mps.protocol: protocol
_`.suffix.method`: The type of a method in a class must end with
``Method``. For example, ``PoolFixMethod``.
_`.suffix.visitor`: The type of a visitor function must end with
``Visitor``. For example, ``TreeVisitor``.
_`.suffix.function`: The type of other functions must end with
``Function``. For example, ``TreeKeyFunction``.
History
-------
- 2014-10-07 GDR_ Created based on job003693_.
.. _job003693: http://www.ravenbrook.com/project/mps/issue/job003693/
.. _GDR: http://www.ravenbrook.com/consultants/gdr
Copyright and License
---------------------
This document is copyright © 2002-2012 [Ravenbrook
Limited](http://www.ravenbrook.com/). All rights reserved. This is an
open source license. Contact Ravenbrook for commercial licensing
options.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
#. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
#. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
#. Redistributions in any form must be accompanied by information on
how to obtain complete source code for this software and any
accompanying software that uses this software. The source code must
either be included in the distribution or be available for no more
than the cost of distribution plus a nominal fee, and must be freely
redistributable under reasonable conditions. For an executable file,
complete source code means the source code for all modules it
contains. It does not include source code for modules or files that
typically accompany the major components of the operating system on
which the executable file runs.
**This software is provided by the copyright holders and contributors
"as is" and any express or implied warranties, including, but not
limited to, the implied warranties of merchantability, fitness for a
particular purpose, or non-infringement, are disclaimed. In no event
shall the copyright holders and contributors be liable for any direct,
indirect, incidental, special, exemplary, or consequential damages
(including, but not limited to, procurement of substitute goods or
services; loss of use, data, or profits; or business interruption)
however caused and on any theory of liability, whether in contract,
strict liability, or tort (including negligence or otherwise) arising in
any way out of the use of this software, even if advised of the
possibility of such damage.**

View file

@ -58,6 +58,7 @@ fix_ The Design of the Generic Fix Function
freelist_ Free list land implementation
guide.hex.trans_ Guide to transliterating the alphabet into hexadecimal
guide.impl.c.format_ Coding standard: conventions for the general format of C source code in the MPS
guide.impl.c.naming_ Coding standard: conventions for internal names
interface-c_ The design of the Memory Pool System interface to C
io_ The design of the MPS I/O subsystem
keyword-arguments_ The design of the MPS mechanism for passing arguments by keyword.
@ -130,6 +131,7 @@ writef_ The design of the MPS writef function
.. _freelist: freelist
.. _guide.hex.trans: guide.hex.trans
.. _guide.impl.c.format: guide.impl.c.format
.. _guide.impl.c.naming: guide.impl.c.naming
.. _interface-c: interface-c
.. _io: io
.. _keyword-arguments: keyword-arguments

View file

@ -57,7 +57,7 @@ _`.def.key`: A *key* is a value associated with each node; the keys
are totally ordered by a client provided comparator.
_`.def.comparator`: A *comparator* is a function that compares keys to
determine their ordering (see also `.type.tree.compare.method`_).
determine their ordering (see also `.type.tree.compare.function`_).
_`.def.successor`: Node *N*\ :subscript:`2` is the *successor* of node
*N*\ :subscript:`1` if *N*\ :subscript:`1` and *N*\ :subscript:`2` are
@ -165,17 +165,17 @@ _`.type.treekey`: ``TreeKey`` is the type of a key associated with a
node in a binary tree. It is an alias for ``void *`` but expresses the
intention.
``typedef TreeKey (*TreeKeyMethod)(Tree tree)``
``typedef TreeKey (*TreeKeyFunction)(Tree tree)``
_`.type.tree.key.method`: A function of type ``TreeKey`` returns the
_`.type.tree.key.function`: A function of type ``TreeKey`` returns the
key associated with a node in a binary tree. (Since there is no space
in a ``TreeStruct`` to store a key, it is expected that the
``TreeStruct`` is embedded in another structure from which the key can
be extracted.)
``typedef Compare (*TreeCompare)(Tree tree, TreeKey key)``
``typedef Compare (*TreeCompareFunction)(Tree tree, TreeKey key)``
_`.type.tree.compare.method`: A function of type ``TreeCompare`` is
_`.type.tree.compare.function`: A function of type ``TreeCompareFunction`` is
required to compare ``key`` with the key the client associates with
that splay tree node ``tree``, and return the appropriate Compare
value (see `.usage.compare`_ for an example). The function compares a
@ -184,10 +184,10 @@ more obvious. This is because the details of the mapping between nodes
and keys is left to the client (see `.type.tree`_), and the splaying
operations compare keys with nodes (see `.impl.splay`_).
``typedef Res (*TreeDescribeMethod)(Tree tree, mps_lib_FILE *stream)``
``typedef Res (*TreeDescribeFunction)(Tree tree, mps_lib_FILE *stream)``
_`.type.tree.describe.method`: A function of type
``TreeDescribeMethod`` is required to write (via ``WriteF()``) a
_`.type.tree.describe.function`: A function of type
``TreeDescribeFunction`` is required to write (via ``WriteF()``) a
client-oriented representation of the splay node. The output should be
non-empty, short, and without newline characters. This is provided for
debugging only.
@ -219,32 +219,32 @@ the root of the splay tree. It is intended that the
`.usage.client-tree`_ for an example). No convenience functions are
provided for allocation or deallocation.
``typedef Bool (*SplayTestNodeMethod)(SplayTree splay, Tree tree, void *closureP, Size closureS)``
``typedef Bool (*SplayTestNodeFunction)(SplayTree splay, Tree tree, void *closureP, Size closureS)``
_`.type.splay.test.node.method`: A function of type
``SplayTestNodeMethod`` required to determine whether the node itself
_`.type.splay.test.node.function`: A function of type
``SplayTestNodeFunction`` required to determine whether the node itself
meets some client determined property (see `.prop`_ and
`.usage.test.node`_ for an example). Parameters ``closureP`` and
``closureS`` describe the environment for the function (see
`.function.splay.find.first`_ and `.function.splay.find.last`_).
``typedef Bool (*SplayTestTreeMethod)(SplayTree splay, Tree tree, void *closureP, Size closureS)``
``typedef Bool (*SplayTestTreeFunction)(SplayTree splay, Tree tree, void *closureP, Size closureS)``
_`.type.splay.test.tree.method`: A function of type
``SplayTestTreeMethod`` is required to determine whether any of the
_`.type.splay.test.tree.function`: A function of type
``SplayTestTreeFunction`` is required to determine whether any of the
nodes in the sub-tree rooted at the given node meet some client
determined property (see `.prop`_ and `.usage.test.tree`_ for an
example). In particular, it must be a precise (not conservative)
indication of whether there are any nodes in the sub-tree for which
the ``testNode`` method (see `.type.splay.test.node.method`_) would
the ``testNode`` function (see `.type.splay.test.node.function`_) would
return ``TRUE``. Parameters ``closureP`` and ``closureS`` describe the
environment for the function (see `.function.splay.find.first`_ and
`.function.splay.find.last`_).
``typedef void (*SplayUpdateNodeMethod)(SplayTree splay, Tree tree)``
``typedef void (*SplayUpdateNodeFunction)(SplayTree splay, Tree tree)``
_`.type.splay.update.node.method`: A function of type
``SplayUpdateNodeMethod`` is required to update any client data
_`.type.splay.update.node.function`: A function of type
``SplayUpdateNodeFunction`` is required to update any client data
structures associated with a node to maintain some client determined
property (see `.prop`_) given that the children of the node have
changed. (See `.usage.callback`_ for an example)
@ -256,9 +256,9 @@ Functions
_`.function.no-thread`: The interface functions are not designed to be
either thread-safe or re-entrant. Clients of the interface are
responsible for synchronization, and for ensuring that client-provided
methods invoked by the splay module (`.type.tree.compare.method`_,
`.type.tree.key.method`_, `.type.splay.test.node.method`_,
`.type.splay.test.tree.method`_, `.type.splay.update.node.method`_) do
functions invoked by the splay module (`.type.tree.compare.function`_,
`.type.tree.key.function`_, `.type.splay.test.node.function`_,
`.type.splay.test.tree.function`_, `.type.splay.update.node.function`_) do
not call functions of the splay module.
``Bool SplayTreeCheck(SplayTree splay)``
@ -267,16 +267,16 @@ _`.function.splay.tree.check`: This is a check function for the
``SplayTree`` type (see guide.impl.c.adt.method.check and
design.mps.check_).
``void SplayTreeInit(SplayTree splay, TreeCompareMethod compare, TreeKeyMethod nodeKey, SplayUpdateNodeMethod updateNode)``
``void SplayTreeInit(SplayTree splay, TreeCompareFunction compare, TreeKeyFunction nodeKey, SplayUpdateNodeFunction updateNode)``
_`.function.splay.tree.init`: This function initialises a
``SplayTree`` (see guide.impl.c.adt.method.init). The ``nodeKey``
function extracts a key from a tree node, and the ``compare`` function
defines a total ordering on keys of nodes (see `.req.order`_). The
effect of supplying a compare method that does not implement a total
ordering is undefined. The ``updateNode`` method is used to keep
effect of supplying a compare function that does not implement a total
ordering is undefined. The ``updateNode`` function is used to keep
client properties up to date when the tree structure changes; the
value ``SplayTrivUpdate`` may be used for this method if there is no
value ``SplayTrivUpdate`` may be used for this function if there is no
need to maintain client properties. (See `.usage.initialization`_ for
an example use).
@ -340,7 +340,7 @@ _`.function.splay.tree.next`: If the tree contains a right neighbour
for ``key``, splay the tree at that node and return it. Otherwise
return ``TreeEMPTY``. See `.req.iterate`_.
``Res SplayTreeDescribe(SplayTree splay, mps_lib_FILE *stream, Count depth, TreeDescribeMethod nodeDescribe)``
``Res SplayTreeDescribe(SplayTree splay, mps_lib_FILE *stream, Count depth, TreeDescribeFunction nodeDescribe)``
_`.function.splay.tree.describe`: This function prints (using
``WriteF()``) to the stream a textual representation of the given
@ -348,25 +348,25 @@ splay tree, using ``nodeDescribe`` to print client-oriented
representations of the nodes (see `.req.debug`_). Provided for
debugging only.
``Bool SplayFindFirst(Tree *nodeReturn, SplayTree splay, SplayTestNodeMethod testNode, SplayTestTreeMethod testTree, void *closureP, Size closureS)``
``Bool SplayFindFirst(Tree *nodeReturn, SplayTree splay, SplayTestNodeFunction testNode, SplayTestTreeFunction testTree, void *closureP, Size closureS)``
_`.function.splay.find.first`: Find the first node in the tree that
satisfies some client property, as determined by the ``testNode`` and
``testTree`` methods (see `.req.property.find`_). ``closureP`` and
``testTree`` functions (see `.req.property.find`_). ``closureP`` and
``closureS`` are arbitrary values, and are passed to the ``testNode``
and ``testTree`` methods which may use the values as closure
and ``testTree`` functions which may use the values as closure
environments. If there is no satisfactory node, return ``FALSE``;
otherwise set ``*nodeReturn`` to the node and return ``TRUE``. See
`.usage.delete`_ for an example.
``Bool SplayFindLast(Tree *nodeReturn, SplayTree splay, SplayTestNodeMethod testNode, SplayTestTreeMethod testTree, void *closureP, Size closureS)``
``Bool SplayFindLast(Tree *nodeReturn, SplayTree splay, SplayTestNodeFunction testNode, SplayTestTreeFunction testTree, void *closureP, Size closureS)``
_`.function.splay.find.last`: As ``SplayFindFirst()``, but find the
last node in the tree that satisfies the client property.
``void SplayNodeRefresh(SplayTree splay, Tree tree, TreeKey key)``
_`.function.splay.node.refresh`: Call the ``updateNode`` method on the
_`.function.splay.node.refresh`: Call the ``updateNode`` function on the
given node, and on any other nodes that may require updating. The
client key for the node must also be supplied; the function splays the
tree at this key. (See `.usage.insert`_ for an example use). This
@ -375,7 +375,7 @@ a node changes (see `.req.property.change`_).
``void SplayNodeUpdate(SplayTree splay, Tree node)``
_`.function.splay.node.update`: Call the ``updateNode`` method on the
_`.function.splay.node.update`: Call the ``updateNode`` function on the
given node, but leave other nodes unchanged. This may be called when a
new node is created, to get the client property off the ground.
@ -388,21 +388,21 @@ implementation provides additional features to permit clients to cache
maximum (or minimum) values of client properties for all the nodes in
a subtree. The splay tree implementation uses the cached values as
part of ``SplayFindFirst()`` and ``SplayFindLast()`` via the
``testNode`` and ``testTree`` methods. The client is free to choose
``testNode`` and ``testTree`` functions. The client is free to choose
how to represent the client property, and how to compute and store the
cached value.
_`.prop.update`: The cached values depend upon the topology of the
tree, which may vary as a result of operations on the tree. The client
is given the opportunity to compute new cache values whenever
necessary, via the ``updateNode`` method (see
necessary, via the ``updateNode`` function (see
`.function.splay.tree.init`_). This happens whenever the tree is
restructured. The client may use the ``SplayNodeRefresh()`` method to
restructured. The client may use the ``SplayNodeRefresh()`` function to
indicate that the client attributes at a node have changed (see
`.req.property.change`_). A call to ``SplayNodeRefresh()`` splays the
tree at the specified node, which may provoke calls to the
``updateNode`` method as a result of the tree restructuring. The
``updateNode`` method will also be called whenever a new splay node is
``updateNode`` function as a result of the tree restructuring. The
``updateNode`` function will also be called whenever a new splay node is
inserted into the tree.
_`.prop.example`: For example, if implementing an address-ordered tree
@ -412,7 +412,7 @@ each block as the client property. The client can then maintain as a
cached value in each node the size of the largest block in the subtree
rooted at that node. This will permit a fast search for the first or
last block of at least a given size. See `.usage.callback`_ for an
example ``updateNode`` method for such a client.
example ``updateNode`` function for such a client.
_`.prop.ops`: The splay operations must cause client properties for
nodes to be updated in the following circumstances (see `.impl`_ for
@ -470,8 +470,8 @@ _`.usage.client-node`: Node structure to embed a ``Tree`` (see `.type.tree`_)::
Size maxSize; /* cached value for maximum size in subtree */
} FreeBlockStruct;
_`.usage.callback`: ``updateNode`` callback method (see
`.type.splay.update.node.method`_)::
_`.usage.callback`: ``updateNode`` callback function (see
`.type.splay.update.node.function`_)::
void FreeBlockUpdateNode(SplayTree splay, Tree tree)
{
@ -499,7 +499,7 @@ _`.usage.callback`: ``updateNode`` callback method (see
freeNode->maxSize = maxSize;
}
_`.usage.compare`: Comparison function (see `.type.tree.compare.method`_)::
_`.usage.compare`: Comparison function (see `.type.tree.compare.function`_)::
Compare FreeBlockCompare(Tree tree, TreeKey key) {
Addr base1, base2, limit2;
@ -518,7 +518,7 @@ _`.usage.compare`: Comparison function (see `.type.tree.compare.method`_)::
}
_`.usage.test.tree`: Test tree function (see
`.type.splay.test.tree.method`_)::
`.type.splay.test.tree.function`_)::
Bool FreeBlockTestTree(SplayTree splay, Tree tree
void *closureP, Size closureS) {
@ -532,7 +532,7 @@ _`.usage.test.tree`: Test tree function (see
}
_`.usage.test.node`: Test node function (see
`.type.splay.test.node.method`_)::
`.type.splay.test.node.function`_)::
Bool FreeBlockTestNode(SplayTree splay, Tree tree
void *closureP, Size closureS) {
@ -895,7 +895,7 @@ _`.error.bad-compare`: Initialising a ``SplayTree`` with a compare
function that is not a valid compare function, or which doesn't
implement a total ordering on splay nodes.
_`.error.bad-describe`: Passing an invalid describe method to
_`.error.bad-describe`: Passing an invalid describe function to
``SplayTreeDescribe()``.
_`.error.out-of-stack`: Stack exhaustion under ``SplayTreeDescribe()``.

View file

@ -14,6 +14,7 @@ Design
freelist
guide.hex.trans
guide.impl.c.format
guide.impl.c.naming
interface-c
keyword-arguments
land