1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-22 23:04:12 -07:00

Landiterate now returns a bool indicating whether all visitor calls returned true.

Copied from Perforce
 Change: 186165
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Gareth Rees 2014-05-18 22:46:16 +01:00
parent 883f4a4c3f
commit 9c3eb68f97
7 changed files with 21 additions and 16 deletions

View file

@ -748,7 +748,7 @@ static Bool cbsIterateVisit(Tree tree, void *closureP, Size closureS)
return TRUE;
}
static void cbsIterate(Land land, LandVisitor visitor,
static Bool cbsIterate(Land land, LandVisitor visitor,
void *closureP, Size closureS)
{
CBS cbs;
@ -769,8 +769,8 @@ static void cbsIterate(Land land, LandVisitor visitor,
closure.visitor = visitor;
closure.closureP = closureP;
closure.closureS = closureS;
(void)TreeTraverse(SplayTreeRoot(splay), splay->compare, splay->nodeKey,
cbsIterateVisit, &closure, 0);
return TreeTraverse(SplayTreeRoot(splay), splay->compare, splay->nodeKey,
cbsIterateVisit, &closure, 0);
}

View file

@ -164,7 +164,7 @@ static Res failoverDelete(Range rangeReturn, Land land, Range range)
}
static void failoverIterate(Land land, LandVisitor visitor, void *closureP, Size closureS)
static Bool failoverIterate(Land land, LandVisitor visitor, void *closureP, Size closureS)
{
Failover fo;
@ -173,8 +173,8 @@ static void failoverIterate(Land land, LandVisitor visitor, void *closureP, Size
AVERT(Failover, fo);
AVER(visitor != NULL);
LandIterate(fo->primary, visitor, closureP, closureS);
LandIterate(fo->secondary, visitor, closureP, closureS);
return LandIterate(fo->primary, visitor, closureP, closureS)
&& LandIterate(fo->secondary, visitor, closureP, closureS);
}

View file

@ -438,7 +438,7 @@ static Res freelistDelete(Range rangeReturn, Land land, Range range)
}
static void freelistIterate(Land land, LandVisitor visitor,
static Bool freelistIterate(Land land, LandVisitor visitor,
void *closureP, Size closureS)
{
Freelist fl;
@ -468,8 +468,9 @@ static void freelistIterate(Land land, LandVisitor visitor,
}
cur = next;
if (!cont)
break;
return FALSE;
}
return TRUE;
}

View file

@ -233,15 +233,17 @@ Res LandDelete(Range rangeReturn, Land land, Range range)
* See <design/land/#function.iterate>
*/
void LandIterate(Land land, LandVisitor visitor, void *closureP, Size closureS)
Bool LandIterate(Land land, LandVisitor visitor, void *closureP, Size closureS)
{
Bool res;
AVERT(Land, land);
AVER(FUNCHECK(visitor));
landEnter(land);
(*land->class->iterate)(land, visitor, closureP, closureS);
res = (*land->class->iterate)(land, visitor, closureP, closureS);
landLeave(land);
return res;
}
@ -503,13 +505,13 @@ static Res landNoDelete(Range rangeReturn, Land land, Range range)
return ResUNIMPL;
}
static void landNoIterate(Land land, LandVisitor visitor, void *closureP, Size closureS)
static Bool landNoIterate(Land land, LandVisitor visitor, void *closureP, Size closureS)
{
AVERT(Land, land);
AVER(visitor != NULL);
UNUSED(closureP);
UNUSED(closureS);
NOOP;
return FALSE;
}
static Bool landNoFind(Range rangeReturn, Range oldRangeReturn, Land land, Size size, FindDelete findDelete)

View file

@ -1014,7 +1014,7 @@ extern void LandDestroy(Land land);
extern void LandFinish(Land land);
extern Res LandInsert(Range rangeReturn, Land land, Range range);
extern Res LandDelete(Range rangeReturn, Land land, Range range);
extern void LandIterate(Land land, LandVisitor visitor, void *closureP, Size closureS);
extern Bool LandIterate(Land land, LandVisitor visitor, void *closureP, Size closureS);
extern Bool LandFindFirst(Range rangeReturn, Range oldRangeReturn, Land land, Size size, FindDelete findDelete);
extern Bool LandFindLast(Range rangeReturn, Range oldRangeReturn, Land land, Size size, FindDelete findDelete);
extern Bool LandFindLargest(Range rangeReturn, Range oldRangeReturn, Land land, Size size, FindDelete findDelete);

View file

@ -272,7 +272,7 @@ typedef Size (*LandSizeMethod)(Land land);
typedef Res (*LandInsertMethod)(Range rangeReturn, Land land, Range range);
typedef Res (*LandDeleteMethod)(Range rangeReturn, Land land, Range range);
typedef Bool (*LandVisitor)(Bool *deleteReturn, Land land, Range range, void *closureP, Size closureS);
typedef void (*LandIterateMethod)(Land land, LandVisitor visitor, void *closureP, Size closureS);
typedef Bool (*LandIterateMethod)(Land land, LandVisitor visitor, void *closureP, Size closureS);
typedef Bool (*LandFindMethod)(Range rangeReturn, Range oldRangeReturn, Land land, Size size, FindDelete findDelete);
typedef Res (*LandFindInZonesMethod)(Range rangeReturn, Range oldRangeReturn, Land land, Size size, ZoneSet zoneSet, Bool high);
typedef Res (*LandDescribeMethod)(Land land, mps_lib_FILE *stream);

View file

@ -164,13 +164,15 @@ strategy.
_`.function.delete.alias`: It is acceptable for ``rangeReturn`` and
``range`` to share storage.
``void LandIterate(Land land, LandIterateMethod iterate, void *closureP, Size closureS)``
``Bool LandIterate(Land land, LandIterateMethod iterate, void *closureP, Size closureS)``
_`.function.iterate`: ``LandIterate()`` is the function used to
iterate all isolated contiguous ranges in a land. It receives a
pointer, ``Size`` closure pair to pass on to the iterator method, and
an iterator method to invoke on every range. If the iterator method
returns ``FALSE``, then the iteration is terminated.
returns ``FALSE``, then the iteration is terminated and
``LandIterate()`` returns ``FALSE``. If all iterator method calls
return ``TRUE``, then ``LandIterate()`` returns ``TRUE``
``Bool LandFindFirst(Range rangeReturn, Range oldRangeReturn, Land land, Size size, FindDelete findDelete)``