Skip to content

Commit 764809b

Browse files
Remove '__' from identifier names (#7038)
1 parent 59b8b36 commit 764809b

File tree

9 files changed

+39
-39
lines changed

9 files changed

+39
-39
lines changed

src/data.table.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
#define IS_FALSE(x) (TYPEOF(x)==LGLSXP && LENGTH(x)==1 && LOGICAL(x)[0]==FALSE)
4747
#define IS_TRUE_OR_FALSE(x) (TYPEOF(x)==LGLSXP && LENGTH(x)==1 && LOGICAL(x)[0]!=NA_LOGICAL)
4848

49-
#define SIZEOF(x) __sizes[TYPEOF(x)]
50-
#define TYPEORDER(x) __typeorder[x]
49+
#define RTYPE_SIZEOF(x) r_type_sizes[TYPEOF(x)]
50+
#define RTYPE_ORDER(x) r_type_order[x]
5151

5252
#ifdef MIN
5353
# undef MIN
@@ -120,8 +120,8 @@ extern SEXP sym_as_posixct;
120120
extern double NA_INT64_D;
121121
extern long long NA_INT64_LL;
122122
extern Rcomplex NA_CPLX; // initialized in init.c; see there for comments
123-
extern size_t __sizes[100]; // max appears to be FUNSXP = 99, see Rinternals.h
124-
extern size_t __typeorder[100]; // __ prefix otherwise if we use these names directly, the SIZEOF define ends up using the local one
123+
extern size_t r_type_sizes[100]; // max appears to be FUNSXP = 99, see Rinternals.h
124+
extern size_t r_type_order[100];
125125

126126
long long DtoLL(double x);
127127
double LLtoD(long long x);

src/dogroups.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
101101
copyMostAttrib(VECTOR_ELT(groups, j), VECTOR_ELT(BY,i)); // not names, otherwise test 778 would fail
102102
SET_STRING_ELT(bynames, i, STRING_ELT(getAttrib(groups,R_NamesSymbol), j));
103103
defineVar(install(CHAR(STRING_ELT(bynames,i))), VECTOR_ELT(BY,i), env); // by vars can be used by name in j as well as via .BY
104-
if (SIZEOF(VECTOR_ELT(BY,i))==0)
104+
if (RTYPE_SIZEOF(VECTOR_ELT(BY,i))==0)
105105
internal_error(__func__, "unsupported size-0 type '%s' in column %d of 'by' should have been caught earlier", type2char(TYPEOF(VECTOR_ELT(BY, i))), i+1); // # nocov
106106
SET_TRUELENGTH(VECTOR_ELT(BY,i), -1); // marker for anySpecialStatic(); see its comments
107107
}
@@ -143,7 +143,7 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
143143

144144
for(int i=0; i<length(SDall); ++i) {
145145
SEXP this = VECTOR_ELT(SDall, i);
146-
if (SIZEOF(this)==0 && TYPEOF(this)!=EXPRSXP)
146+
if (RTYPE_SIZEOF(this)==0 && TYPEOF(this)!=EXPRSXP)
147147
internal_error(__func__, "size-0 type %d in .SD column %d should have been caught earlier", TYPEOF(this), i); // # nocov
148148
if (LENGTH(this) != maxGrpSize)
149149
internal_error(__func__, "SDall %d length = %d != %d", i+1, LENGTH(this), maxGrpSize); // # nocov
@@ -158,7 +158,7 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
158158
internal_error(__func__, "length(xknames)!=length(xSD)"); // # nocov
159159
SEXP *xknameSyms = (SEXP *)R_alloc(length(xknames), sizeof(*xknameSyms));
160160
for(int i=0; i<length(xSD); ++i) {
161-
if (SIZEOF(VECTOR_ELT(xSD, i))==0)
161+
if (RTYPE_SIZEOF(VECTOR_ELT(xSD, i))==0)
162162
internal_error(__func__, "type %d in .xSD column %d should have been caught by now", TYPEOF(VECTOR_ELT(xSD, i)), i); // # nocov
163163
xknameSyms[i] = install(CHAR(STRING_ELT(xknames, i)));
164164
}
@@ -541,11 +541,11 @@ SEXP growVector(SEXP x, const R_len_t newlen)
541541
return newx;
542542
}
543543
switch (TYPEOF(x)) {
544-
case RAWSXP: memcpy(RAW(newx), RAW_RO(x), len*SIZEOF(x)); break;
545-
case LGLSXP: memcpy(LOGICAL(newx), LOGICAL_RO(x), len*SIZEOF(x)); break;
546-
case INTSXP: memcpy(INTEGER(newx), INTEGER_RO(x), len*SIZEOF(x)); break;
547-
case REALSXP: memcpy(REAL(newx), REAL_RO(x), len*SIZEOF(x)); break;
548-
case CPLXSXP: memcpy(COMPLEX(newx), COMPLEX_RO(x), len*SIZEOF(x)); break;
544+
case RAWSXP: memcpy(RAW(newx), RAW_RO(x), len*RTYPE_SIZEOF(x)); break;
545+
case LGLSXP: memcpy(LOGICAL(newx), LOGICAL_RO(x), len*RTYPE_SIZEOF(x)); break;
546+
case INTSXP: memcpy(INTEGER(newx), INTEGER_RO(x), len*RTYPE_SIZEOF(x)); break;
547+
case REALSXP: memcpy(REAL(newx), REAL_RO(x), len*RTYPE_SIZEOF(x)); break;
548+
case CPLXSXP: memcpy(COMPLEX(newx), COMPLEX_RO(x), len*RTYPE_SIZEOF(x)); break;
549549
case STRSXP : {
550550
const SEXP *xd = SEXPPTR_RO(x);
551551
for (int i=0; i<len; ++i)

src/fmelt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ SEXP getvaluecols(SEXP DT, SEXP dtnames, Rboolean valfactor, Rboolean verbose, s
524524
ithisidx = INTEGER(thisidx);
525525
thislen = length(thisidx);
526526
}
527-
size_t size = SIZEOF(thiscol);
527+
size_t size = RTYPE_SIZEOF(thiscol);
528528
switch (TYPEOF(target)) {
529529
case VECSXP :
530530
if (data->narm) {
@@ -697,7 +697,7 @@ SEXP getidcols(SEXP DT, SEXP dtnames, Rboolean verbose, struct processData *data
697697
for (int i=0; i<data->lids; ++i) {
698698
int counter = 0;
699699
SEXP thiscol = VECTOR_ELT(DT, INTEGER(data->idcols)[i]-1);
700-
size_t size = SIZEOF(thiscol);
700+
size_t size = RTYPE_SIZEOF(thiscol);
701701
SEXP target;
702702
SET_VECTOR_ELT(ansids, i, target=allocVector(TYPEOF(thiscol), data->totlen) );
703703
copyMostAttrib(thiscol, target); // all but names,dim and dimnames. And if so, we want a copy here, not keepattr's SET_ATTRIB.

src/forder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ SEXP issorted(SEXP x, SEXP by)
14291429
int c = INTEGER(by)[j];
14301430
if (c<1 || c>length(x)) STOP(_("issorted 'by' [%d] out of range [1,%d]"), c, length(x));
14311431
SEXP col = VECTOR_ELT(x, c-1);
1432-
sizes[j] = SIZEOF(col);
1432+
sizes[j] = RTYPE_SIZEOF(col);
14331433
switch(TYPEOF(col)) {
14341434
case INTSXP: case LGLSXP:
14351435
types[j] = 0;

src/freadR.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ size_t allocateDT(int8_t *typeArg, int8_t *sizeArg, int ncolArg, int ndrop, size
479479
else if (selectRank) setAttrib(DT, sym_colClassesAs, subsetVector(colClassesAs, selectRank)); // reorder the colClassesAs
480480
}
481481
// TODO: move DT size calculation into a separate function (since the final size is different from the initial size anyways)
482-
size_t DTbytes = SIZEOF(DT)*(ncol-ndrop)*2; // the VECSXP and its column names (exclude global character cache usage)
482+
size_t DTbytes = RTYPE_SIZEOF(DT)*(ncol-ndrop)*2; // the VECSXP and its column names (exclude global character cache usage)
483483

484484
// For each column we could have one of the following cases:
485485
// * if the DataTable is "new", then make a new vector
@@ -520,7 +520,7 @@ size_t allocateDT(int8_t *typeArg, int8_t *sizeArg, int ncolArg, int ndrop, size
520520
setAttrib(thiscol, sym_tzone, ScalarString(char_UTC)); // see news for v1.13.0
521521
}
522522
SET_TRUELENGTH(thiscol, allocNrow);
523-
DTbytes += SIZEOF(thiscol)*allocNrow;
523+
DTbytes += RTYPE_SIZEOF(thiscol)*allocNrow;
524524
}
525525
resi++;
526526
}

src/init.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ SEXP sym_as_posixct;
4646
double NA_INT64_D;
4747
long long NA_INT64_LL;
4848
Rcomplex NA_CPLX;
49-
size_t __sizes[100];
50-
size_t __typeorder[100];
49+
size_t r_type_sizes[100];
50+
size_t r_type_order[100];
5151

5252
static const
5353
R_CallMethodDef callMethods[] = {
@@ -160,15 +160,15 @@ R_ExternalMethodDef externalMethods[] = {
160160
};
161161

162162
static void setSizes(void) {
163-
for (int i=0; i<100; ++i) { __sizes[i]=0; __typeorder[i]=0; }
163+
for (int i=0; i<100; ++i) { r_type_sizes[i]=0; r_type_order[i]=0; }
164164
// only these types are currently allowed as column types :
165-
__sizes[LGLSXP] = sizeof(int); __typeorder[LGLSXP] = 0;
166-
__sizes[RAWSXP] = sizeof(Rbyte); __typeorder[RAWSXP] = 1;
167-
__sizes[INTSXP] = sizeof(int); __typeorder[INTSXP] = 2; // integer and factor
168-
__sizes[REALSXP] = sizeof(double); __typeorder[REALSXP] = 3; // numeric and integer64
169-
__sizes[CPLXSXP] = sizeof(Rcomplex); __typeorder[CPLXSXP] = 4;
170-
__sizes[STRSXP] = sizeof(SEXP *); __typeorder[STRSXP] = 5;
171-
__sizes[VECSXP] = sizeof(SEXP *); __typeorder[VECSXP] = 6; // list column
165+
r_type_sizes[LGLSXP] = sizeof(int); r_type_order[LGLSXP] = 0;
166+
r_type_sizes[RAWSXP] = sizeof(Rbyte); r_type_order[RAWSXP] = 1;
167+
r_type_sizes[INTSXP] = sizeof(int); r_type_order[INTSXP] = 2; // integer and factor
168+
r_type_sizes[REALSXP] = sizeof(double); r_type_order[REALSXP] = 3; // numeric and integer64
169+
r_type_sizes[CPLXSXP] = sizeof(Rcomplex); r_type_order[CPLXSXP] = 4;
170+
r_type_sizes[STRSXP] = sizeof(SEXP *); r_type_order[STRSXP] = 5;
171+
r_type_sizes[VECSXP] = sizeof(SEXP *); r_type_order[VECSXP] = 6; // list column
172172
if (sizeof(char *)>8) error(_("Pointers are %zu bytes, greater than 8. We have not tested on any architecture greater than 64bit yet."), sizeof(char *));
173173
// One place we need the largest sizeof is the working memory malloc in reorder.c
174174
}

src/rbindlist.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ SEXP rbindlist(SEXP l, SEXP usenamesArg, SEXP fillArg, SEXP idcolArg, SEXP ignor
297297
}
298298
SEXP thisCol = VECTOR_ELT(li, w);
299299
int thisType = TYPEOF(thisCol);
300-
// Use >= for #546 -- TYPEORDER=0 for both LGLSXP and EXPRSXP (but also NULL)
301-
if (TYPEORDER(thisType)>=TYPEORDER(maxType) && !isNull(thisCol)) maxType=thisType;
300+
// Use >= for #546 -- RTYPE_ORDER=0 for both LGLSXP and EXPRSXP (but also NULL)
301+
if (RTYPE_ORDER(thisType)>=RTYPE_ORDER(maxType) && !isNull(thisCol)) maxType=thisType;
302302
if (isFactor(thisCol)) {
303303
if (isNull(getAttrib(thisCol,R_LevelsSymbol))) error(_("Column %d of item %d has type 'factor' but has no levels; i.e. malformed."), w+1, i+1);
304304
factor = true;
@@ -497,7 +497,7 @@ SEXP rbindlist(SEXP l, SEXP usenamesArg, SEXP fillArg, SEXP idcolArg, SEXP ignor
497497
}
498498
}
499499
} else {
500-
memcpy(targetd+ansloc, id, thisnrow*SIZEOF(thisCol));
500+
memcpy(targetd+ansloc, id, thisnrow*RTYPE_SIZEOF(thisCol));
501501
}
502502
}
503503
} else {

src/reorder.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ SEXP reorder(SEXP x, SEXP order)
1818
ncol = length(x);
1919
for (int i=0; i<ncol; i++) {
2020
SEXP v = VECTOR_ELT(x,i);
21-
if (SIZEOF(v)!=4 && SIZEOF(v)!=8 && SIZEOF(v)!=16 && SIZEOF(v)!=1)
22-
error(_("Item %d of list is type '%s' which isn't yet supported (SIZEOF=%zu)"), i+1, type2char(TYPEOF(v)), SIZEOF(v));
21+
if (RTYPE_SIZEOF(v)!=4 && RTYPE_SIZEOF(v)!=8 && RTYPE_SIZEOF(v)!=16 && RTYPE_SIZEOF(v)!=1)
22+
error(_("Item %d of list is type '%s' which isn't yet supported (RTYPE_SIZEOF=%zu)"), i+1, type2char(TYPEOF(v)), RTYPE_SIZEOF(v));
2323
if (length(v)!=nrow)
2424
error(_("Column %d is length %d which differs from length of column 1 (%d). Invalid data.table."), i+1, length(v), nrow);
25-
if (SIZEOF(v) > maxSize)
26-
maxSize=SIZEOF(v);
25+
if (RTYPE_SIZEOF(v) > maxSize)
26+
maxSize=RTYPE_SIZEOF(v);
2727
if (ALTREP(v)) SET_VECTOR_ELT(x, i, copyAsPlain(v));
2828
}
2929
copySharedColumns(x); // otherwise two columns which point to the same vector would be reordered and then re-reordered, issues linked in PR#3768
3030
} else {
31-
if (SIZEOF(x)!=4 && SIZEOF(x)!=8 && SIZEOF(x)!=16 && SIZEOF(x)!=1)
32-
error(_("reorder accepts vectors but this non-VECSXP is type '%s' which isn't yet supported (SIZEOF=%zu)"), type2char(TYPEOF(x)), SIZEOF(x));
31+
if (RTYPE_SIZEOF(x)!=4 && RTYPE_SIZEOF(x)!=8 && RTYPE_SIZEOF(x)!=16 && RTYPE_SIZEOF(x)!=1)
32+
error(_("reorder accepts vectors but this non-VECSXP is type '%s' which isn't yet supported (RTYPE_SIZEOF=%zu)"), type2char(TYPEOF(x)), RTYPE_SIZEOF(x));
3333
if (ALTREP(x)) internal_error(__func__, "cannot reorder an ALTREP vector. Please see NEWS item 2 in v1.11.4"); // # nocov
34-
maxSize = SIZEOF(x);
34+
maxSize = RTYPE_SIZEOF(x);
3535
nrow = length(x);
3636
ncol = 1;
3737
}
@@ -67,7 +67,7 @@ SEXP reorder(SEXP x, SEXP order)
6767

6868
for (int i=0; i<ncol; ++i) {
6969
const SEXP v = isNewList(x) ? VECTOR_ELT(x,i) : x;
70-
const size_t size = SIZEOF(v); // size_t, otherwise #61 (integer overflow in memcpy)
70+
const size_t size = RTYPE_SIZEOF(v); // size_t, otherwise #61 (integer overflow in memcpy)
7171
if (size==4) {
7272
const int *restrict vd = DATAPTR_RO(v);
7373
int *restrict tmp = (int *)TMP;

src/shift.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ SEXP shift(SEXP obj, SEXP k, SEXP fill, SEXP type)
3838
SEXP ans = PROTECT(allocVector(VECSXP, nk * nx)); nprotect++;
3939
for (int i=0; i<nx; i++) {
4040
SEXP elem = VECTOR_ELT(x, i);
41-
size_t size = SIZEOF(elem);
41+
size_t size = RTYPE_SIZEOF(elem);
4242
R_xlen_t xrows = xlength(elem);
4343
SEXP thisfill = PROTECT(coerceAs(fill, elem, ScalarLogical(0))); // #4865 use coerceAs for type coercion
4444
switch (TYPEOF(elem)) {

0 commit comments

Comments
 (0)