Skip to content

Commit

Permalink
Rboolean -> bool
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@87863 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
ripley committed Mar 2, 2025
1 parent e7d009e commit 8898e12
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 146 deletions.
8 changes: 4 additions & 4 deletions src/main/Rdynload.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static SEXP Rf_MakeDLLInfo(DllInfo *info);

static SEXP createRSymbolObject(SEXP sname, DL_FUNC f,
R_RegisteredNativeSymbol *symbol,
Rboolean withRegistrationInfo);
bool withRegistrationInfo);

static DllInfo *R_RegisterDLL(HINSTANCE handle, const char *path);

Expand Down Expand Up @@ -672,7 +672,7 @@ Rf_freeDllInfo(DllInfo *info)
typedef void (*DllInfoUnloadCall)(DllInfo *);
typedef DllInfoUnloadCall DllInfoInitCall;

static Rboolean
static bool
R_callDLLUnload(DllInfo *dllInfo)
{
char buf[1024];
Expand Down Expand Up @@ -1470,7 +1470,7 @@ R_getSymbolInfo(SEXP sname, SEXP spackage, SEXP withRegistrationInfo)

if(f)
sym = createRSymbolObject(sname, f, &symbol,
asRbool(withRegistrationInfo, R_NilValue));
asBool2(withRegistrationInfo, R_NilValue));

vmaxset(vmax);
return sym;
Expand Down Expand Up @@ -1511,7 +1511,7 @@ R_getDllTable(void)

static SEXP
createRSymbolObject(SEXP sname, DL_FUNC f, R_RegisteredNativeSymbol *symbol,
Rboolean withRegistrationInfo)
bool withRegistrationInfo)
{
SEXP tmp, klass, sym, names;
int n = (symbol->type != R_ANY_SYM) ? 4 : 3;
Expand Down
36 changes: 18 additions & 18 deletions src/main/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ attribute_hidden SEXP do_lapply(SEXP call, SEXP op, SEXP args, SEXP rho)
XX = PROTECT(eval(CAR(args), rho));
R_xlen_t n = xlength(XX); // a vector, so will be valid.
FUN = checkArgIsSymbol(CADR(args));
Rboolean realIndx = n > INT_MAX;
bool realIndx = n > INT_MAX;

SEXP ans = PROTECT(allocVector(VECSXP, n));
SEXP names = getAttrib(XX, R_NamesSymbol);
Expand Down Expand Up @@ -99,7 +99,7 @@ attribute_hidden SEXP do_vapply(SEXP call, SEXP op, SEXP args, SEXP rho)
R_xlen_t i, n;
int commonLen;
int useNames, rnk_v = -1; // = array_rank(value) := length(dim(value))
Rboolean array_value;
bool array_value;
SEXPTYPE commonType;
PROTECT_INDEX index = 0; /* initialize to avoid a warning */

Expand All @@ -116,7 +116,7 @@ attribute_hidden SEXP do_vapply(SEXP call, SEXP op, SEXP args, SEXP rho)

n = xlength(XX);
if (n == NA_INTEGER) error(_("invalid length"));
Rboolean realIndx = n > INT_MAX;
bool realIndx = n > INT_MAX;

commonLen = length(value);
if (commonLen > 1 && n > INT_MAX)
Expand Down Expand Up @@ -179,7 +179,7 @@ attribute_hidden SEXP do_vapply(SEXP call, SEXP op, SEXP args, SEXP rho)
commonLen, (long long)i+1, length(val));
valType = TYPEOF(val);
if (valType != commonType) {
Rboolean okay = FALSE;
bool okay = false;
switch (commonType) {
case CPLXSXP: okay = (valType == REALSXP) || (valType == INTSXP)
|| (valType == LGLSXP); break;
Expand Down Expand Up @@ -284,10 +284,10 @@ attribute_hidden SEXP do_vapply(SEXP call, SEXP op, SEXP args, SEXP rho)

// Apply FUN() to X recursively; workhorse of rapply()
static SEXP do_one(SEXP X, SEXP FUN, SEXP classes, SEXP deflt,
Rboolean replace, SEXP rho)
bool replace, SEXP rho)
{
SEXP ans, names, klass;
Rboolean matched = FALSE;
bool matched = false;

/* if X is a list, recurse. Otherwise if it matches classes call f */
if(X == R_NilValue || isVectorList(X)) {
Expand All @@ -306,13 +306,13 @@ static SEXP do_one(SEXP X, SEXP FUN, SEXP classes, SEXP deflt,
return ans;
}
if(strcmp(CHAR(STRING_ELT(classes, 0)), "ANY") == 0) /* ASCII */
matched = TRUE;
matched = true;
else {
PROTECT(klass = R_data_class(X, FALSE));
PROTECT(klass = R_data_class(X, false));
for(int i = 0; i < LENGTH(klass); i++)
for(int j = 0; j < length(classes); j++)
if(Seql(STRING_ELT(klass, i), STRING_ELT(classes, j)))
matched = TRUE;
matched = true;
UNPROTECT(1);
}
if(matched) {
Expand Down Expand Up @@ -349,7 +349,7 @@ attribute_hidden SEXP do_rapply(SEXP call, SEXP op, SEXP args, SEXP rho)
deflt = CAR(args); args = CDR(args);
how = CAR(args);
if(!isString(how)) error(_("invalid '%s' argument"), "how");
Rboolean replace = strcmp(CHAR(STRING_ELT(how, 0)), "replace") == 0; /* ASCII */
bool replace = strcmp(CHAR(STRING_ELT(how, 0)), "replace") == 0; /* ASCII */
R_xlen_t n = xlength(X);
if (replace) {
PROTECT(ans = shallow_duplicate(X));
Expand Down Expand Up @@ -380,9 +380,9 @@ static int islistfactor(SEXP X)
for(int i = 0; i < n; i++) {
int isLF = islistfactor(VECTOR_ELT(X, i));
if(!isLF)
return FALSE;
else if(isLF == TRUE)
ans = TRUE;
return false;
else if(isLF == true)
ans = true;
// else isLF is NA
}
return ans;
Expand All @@ -399,19 +399,19 @@ attribute_hidden SEXP do_islistfactor(SEXP call, SEXP op, SEXP args, SEXP rho)
{
checkArity(op, args);
SEXP X = CAR(args);
Rboolean recursive = asRbool(CADR(args), call);
bool recursive = asBool2(CADR(args), call);
int n = length(X);
if(n == 0 || !isVectorList(X))
return ScalarLogical(FALSE);
return ScalarLogical(false);

if(!recursive) {
for(int i = 0; i < n; i++)
if(!isFactor(VECTOR_ELT(X, i)))
return ScalarLogical(FALSE);
return ScalarLogical(false);

return ScalarLogical(TRUE);
return ScalarLogical(true);
}
else { // recursive: isVectorList(X) <==> X is VECSXP or EXPRSXP
return ScalarLogical((islistfactor(X) == TRUE) ? TRUE : FALSE);
return ScalarLogical((islistfactor(X) == true) ? true : false);
}
}
20 changes: 10 additions & 10 deletions src/main/attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@ static SEXP row_names_gets(SEXP vec, SEXP val)
return ans;
}
if(isInteger(val)) {
Rboolean OK_compact = TRUE;
bool OK_compact = TRUE;
int i, n = LENGTH(val);
if(n == 2 && INTEGER(val)[0] == NA_INTEGER) {
n = INTEGER(val)[1];
} else if (n > 2) {
for(i = 0; i < n; i++)
if(INTEGER(val)[i] != i+1) {
OK_compact = FALSE;
OK_compact = false;
break;
}
} else OK_compact = FALSE;
} else OK_compact = false;
if(OK_compact) {
/* we hide the length in an impossible integer vector */
PROTECT(vec);
Expand Down Expand Up @@ -96,14 +96,14 @@ static SEXP stripAttrib(SEXP tag, SEXP lst)
return lst;
}

static Rboolean isOneDimensionalArray(SEXP vec)
static bool isOneDimensionalArray(SEXP vec)
{
if(isVector(vec) || isList(vec) || isLanguage(vec)) {
SEXP s = getAttrib(vec, R_DimSymbol);
if(TYPEOF(s) == INTSXP && LENGTH(s) == 1)
return TRUE;
}
return FALSE;
return false;
}

/* NOTE: For environments serialize.c calls this function to find if
Expand All @@ -127,7 +127,7 @@ attribute_hidden SEXP getAttrib0(SEXP vec, SEXP name)
int len = length(vec);
PROTECT(s = allocVector(STRSXP, len));
int i = 0;
Rboolean any = FALSE;
bool any = false;
for ( ; vec != R_NilValue; vec = CDR(vec), i++) {
if (TAG(vec) == R_NilValue)
{
Expand Down Expand Up @@ -320,7 +320,7 @@ void copyMostAttribNoTs(SEXP inp, SEXP ans)
} else if (TAG(s) == R_ClassSymbol) {
SEXP cl = CAR(s);
int i;
Rboolean ists = FALSE;
bool ists = false;
for (i = 0; i < LENGTH(cl); i++)
if (strcmp(CHAR(STRING_ELT(cl, i)), "ts") == 0) { /* ASCII */
ists = TRUE;
Expand Down Expand Up @@ -529,7 +529,7 @@ SEXP classgets(SEXP vec, SEXP klass)

/* HOWEVER, it is the way that the object bit gets set/unset */

Rboolean isfactor = FALSE;
bool isfactor = false;

if (vec == R_NilValue)
error(_("attempt to set an attribute on NULL"));
Expand Down Expand Up @@ -712,7 +712,7 @@ static SEXP cache_class(const char *class, SEXP klass)
return klass;
}

static SEXP S4_extends(SEXP klass, Rboolean use_tab) {
static SEXP S4_extends(SEXP klass, bool use_tab) {
static SEXP s_extends = 0, s_extendsForS3;
SEXP e, val; const char *class;
const void *vmax;
Expand Down Expand Up @@ -746,7 +746,7 @@ static SEXP S4_extends(SEXP klass, Rboolean use_tab) {

attribute_hidden SEXP R_S4_extends(SEXP klass, SEXP useTable)
{
return S4_extends(klass, asRbool(useTable, R_NilValue));
return S4_extends(klass, asBool2(useTable, R_NilValue));
}


Expand Down
Loading

0 comments on commit 8898e12

Please sign in to comment.