Skip to content

Commit 3c96078

Browse files
author
ripley
committed
convert Callbacks.h to bool
git-svn-id: https://svn.r-project.org/R/trunk@87937 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent b6e350d commit 3c96078

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

src/main/main.c

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ attribute_hidden void nl_Rdummy(void)
6868
*/
6969

7070
attribute_hidden
71-
void Rf_callToplevelHandlers(SEXP expr, SEXP value, Rboolean succeeded,
72-
Rboolean visible);
71+
void Rf_callToplevelHandlers(SEXP expr, SEXP value, bool succeeded,
72+
bool visible);
7373

7474
static int ParseBrowser(SEXP, SEXP);
7575

@@ -200,7 +200,7 @@ Rf_ReplIteration(SEXP rho, int savestack, int browselevel, R_ReplState *state)
200200
{
201201
int c, browsevalue;
202202
SEXP value, thisExpr;
203-
bool wasDisplayed = FALSE;
203+
bool wasDisplayed = false;
204204

205205
/* clear warnings that might have accumulated during a jump to top level */
206206
if (R_CollectWarnings)
@@ -271,7 +271,7 @@ Rf_ReplIteration(SEXP rho, int savestack, int browselevel, R_ReplState *state)
271271
PrintValueEnv(value, rho);
272272
if (R_CollectWarnings)
273273
PrintWarnings();
274-
Rf_callToplevelHandlers(thisExpr, value, TRUE, wasDisplayed);
274+
Rf_callToplevelHandlers(thisExpr, value, true, wasDisplayed);
275275
R_CurrentExpr = value; /* Necessary? Doubt it. */
276276
UNPROTECT(2); /* thisExpr, value */
277277
if (R_BrowserLastCommand == 'S') R_BrowserLastCommand = 's';
@@ -333,7 +333,7 @@ static void check_session_exit(void)
333333
error is signaled from one of the functions called. The
334334
'exiting' variable identifies this and results in
335335
R_Suicide. */
336-
static bool exiting = FALSE;
336+
static bool exiting = false;
337337
if (exiting)
338338
R_Suicide(_("error during cleanup\n"));
339339
else {
@@ -368,7 +368,7 @@ int R_ReplDLLdo1(void)
368368
int c;
369369
ParseStatus status;
370370
SEXP rho = R_GlobalEnv, lastExpr;
371-
bool wasDisplayed = FALSE;
371+
bool wasDisplayed = false;
372372

373373
if(!*DLLbufp) {
374374
R_Busy(0);
@@ -405,7 +405,7 @@ int R_ReplDLLdo1(void)
405405
PrintValueEnv(R_CurrentExpr, rho);
406406
if (R_CollectWarnings)
407407
PrintWarnings();
408-
Rf_callToplevelHandlers(lastExpr, R_CurrentExpr, TRUE, wasDisplayed);
408+
Rf_callToplevelHandlers(lastExpr, R_CurrentExpr, true, wasDisplayed);
409409
UNPROTECT(1);
410410
R_IoBufferWriteReset(&R_ConsoleIob);
411411
R_Busy(0);
@@ -1615,14 +1615,14 @@ static R_ToplevelCallbackEl *Rf_CurrentToplevelHandler = NULL;
16151615

16161616
/* A running handler attempted to remove itself from Rf_ToplevelTaskHandlers,
16171617
do it after it finishes. */
1618-
static Rboolean Rf_DoRemoveCurrentToplevelHandler = FALSE;
1618+
static bool Rf_DoRemoveCurrentToplevelHandler = false;
16191619

16201620
/* A handler has been removed from the Rf_ToplevelTaskHandlers. */
1621-
static Rboolean Rf_RemovedToplevelHandlers = FALSE;
1621+
static bool Rf_RemovedToplevelHandlers = false;
16221622

16231623
/* Flag to ensure that the top-level handlers aren't called recursively.
16241624
Simple state to indicate that they are currently being run. */
1625-
static Rboolean Rf_RunningToplevelHandlers = FALSE;
1625+
static bool Rf_RunningToplevelHandlers = false;
16261626

16271627
/**
16281628
This is the C-level entry point for registering a handler
@@ -1677,24 +1677,24 @@ Rf_addTaskCallback(R_ToplevelCallback cb, void *data,
16771677
static void removeToplevelHandler(R_ToplevelCallbackEl *e)
16781678
{
16791679
if (Rf_CurrentToplevelHandler == e)
1680-
Rf_DoRemoveCurrentToplevelHandler = TRUE; /* postpone */
1680+
Rf_DoRemoveCurrentToplevelHandler = true; /* postpone */
16811681
else {
1682-
Rf_RemovedToplevelHandlers = TRUE;
1682+
Rf_RemovedToplevelHandlers = true;
16831683
if(e->finalizer)
16841684
e->finalizer(e->data);
16851685
free(e->name);
16861686
free(e);
16871687
}
16881688
}
16891689

1690-
attribute_hidden Rboolean
1690+
attribute_hidden bool
16911691
Rf_removeTaskCallbackByName(const char *name)
16921692
{
16931693
R_ToplevelCallbackEl *el = Rf_ToplevelTaskHandlers, *prev = NULL;
1694-
Rboolean status = TRUE;
1694+
bool status = true;
16951695

16961696
if(!Rf_ToplevelTaskHandlers) {
1697-
return(FALSE); /* error("there are no task callbacks registered"); */
1697+
return(false); /* error("there are no task callbacks registered"); */
16981698
}
16991699

17001700
while(el) {
@@ -1712,7 +1712,7 @@ Rf_removeTaskCallbackByName(const char *name)
17121712
if(el)
17131713
removeToplevelHandler(el);
17141714
else
1715-
status = FALSE;
1715+
status = false;
17161716

17171717
return(status);
17181718
}
@@ -1721,11 +1721,11 @@ Rf_removeTaskCallbackByName(const char *name)
17211721
Remove the top-level task handler/callback identified by
17221722
its position in the list of callbacks.
17231723
*/
1724-
attribute_hidden Rboolean
1724+
attribute_hidden bool
17251725
Rf_removeTaskCallbackByIndex(int id)
17261726
{
17271727
R_ToplevelCallbackEl *el = Rf_ToplevelTaskHandlers, *tmp = NULL;
1728-
Rboolean status = TRUE;
1728+
bool status = true;
17291729

17301730
if(id < 0)
17311731
error(_("negative index passed to R_removeTaskCallbackByIndex"));
@@ -1750,7 +1750,7 @@ Rf_removeTaskCallbackByIndex(int id)
17501750
if(tmp)
17511751
removeToplevelHandler(tmp);
17521752
else
1753-
status = FALSE;
1753+
status = false;
17541754

17551755
return(status);
17561756
}
@@ -1768,17 +1768,17 @@ attribute_hidden SEXP
17681768
R_removeTaskCallback(SEXP which)
17691769
{
17701770
int id;
1771-
Rboolean val;
1771+
bool val;
17721772

17731773
if(TYPEOF(which) == STRSXP) {
17741774
if (LENGTH(which) == 0)
1775-
val = FALSE;
1775+
val = false;
17761776
else
17771777
val = Rf_removeTaskCallbackByName(CHAR(STRING_ELT(which, 0)));
17781778
} else {
17791779
id = asInteger(which);
17801780
if (id != NA_INTEGER) val = Rf_removeTaskCallbackByIndex(id - 1);
1781-
else val = FALSE;
1781+
else val = false;
17821782
}
17831783
return ScalarLogical(val);
17841784
}
@@ -1819,28 +1819,28 @@ R_getTaskCallbackNames(void)
18191819

18201820
/* This is not used in R and in no header */
18211821
void
1822-
Rf_callToplevelHandlers(SEXP expr, SEXP value, Rboolean succeeded,
1823-
Rboolean visible)
1822+
Rf_callToplevelHandlers(SEXP expr, SEXP value, bool succeeded,
1823+
bool visible)
18241824
{
18251825
R_ToplevelCallbackEl *h, *prev = NULL;
1826-
Rboolean again;
1826+
bool again;
18271827

1828-
if(Rf_RunningToplevelHandlers == TRUE)
1828+
if(Rf_RunningToplevelHandlers == true)
18291829
return;
18301830

18311831
h = Rf_ToplevelTaskHandlers;
1832-
Rf_RunningToplevelHandlers = TRUE;
1832+
Rf_RunningToplevelHandlers = true;
18331833
while(h) {
1834-
Rf_RemovedToplevelHandlers = FALSE;
1835-
Rf_DoRemoveCurrentToplevelHandler = FALSE;
1834+
Rf_RemovedToplevelHandlers = false;
1835+
Rf_DoRemoveCurrentToplevelHandler = false;
18361836
Rf_CurrentToplevelHandler = h;
18371837
again = (h->cb)(expr, value, succeeded, visible, h->data);
18381838
Rf_CurrentToplevelHandler = NULL;
18391839

18401840
if (Rf_DoRemoveCurrentToplevelHandler) {
18411841
/* the handler attempted to remove itself, PR#18508 */
1842-
Rf_DoRemoveCurrentToplevelHandler = FALSE;
1843-
again = FALSE;
1842+
Rf_DoRemoveCurrentToplevelHandler = false;
1843+
again = false;
18441844
}
18451845
if (Rf_RemovedToplevelHandlers) {
18461846
/* some handlers were removed, but not "h" -> recompute "prev" */
@@ -1876,7 +1876,7 @@ Rf_callToplevelHandlers(SEXP expr, SEXP value, Rboolean succeeded,
18761876
}
18771877
}
18781878

1879-
Rf_RunningToplevelHandlers = FALSE;
1879+
Rf_RunningToplevelHandlers = false;
18801880
}
18811881

18821882

@@ -1886,9 +1886,9 @@ static void defineVarInc(SEXP sym, SEXP val, SEXP rho)
18861886
INCREMENT_NAMED(val); /* in case this is used in a NAMED build */
18871887
}
18881888

1889-
attribute_hidden Rboolean
1890-
R_taskCallbackRoutine(SEXP expr, SEXP value, Rboolean succeeded,
1891-
Rboolean visible, void *userData)
1889+
attribute_hidden bool
1890+
R_taskCallbackRoutine(SEXP expr, SEXP value, bool succeeded,
1891+
bool visible, void *userData)
18921892
{
18931893
/* install some symbols */
18941894
static SEXP R_cbSym = NULL;
@@ -1909,7 +1909,7 @@ R_taskCallbackRoutine(SEXP expr, SEXP value, Rboolean succeeded,
19091909
SEXP f = (SEXP) userData;
19101910
SEXP e, val, cur, rho;
19111911
int errorOccurred;
1912-
Rboolean again, useData = (Rboolean)LOGICAL(VECTOR_ELT(f, 2))[0];
1912+
bool again, useData = (bool)LOGICAL(VECTOR_ELT(f, 2))[0];
19131913

19141914
/* create an environment with bindings for the function and arguments */
19151915
PROTECT(rho = NewEnvironment(R_NilValue, R_NilValue, R_GlobalEnv));
@@ -1948,10 +1948,10 @@ R_taskCallbackRoutine(SEXP expr, SEXP value, Rboolean succeeded,
19481948
/* It would be nice to identify the function. */
19491949
warning(_("top-level task callback did not return a logical value"));
19501950
}
1951-
again = (Rboolean) asLogical(val);
1951+
again = (bool) asLogical(val);
19521952
} else {
19531953
/* warning("error occurred in top-level task callback\n"); */
1954-
again = FALSE;
1954+
again = false;
19551955
}
19561956

19571957
UNPROTECT(3); /* rho, e, val */

0 commit comments

Comments
 (0)