Skip to content

Commit 7a5eddd

Browse files
author
ripley
committed
start annotating the use of Rboolean in public headers
git-svn-id: https://svn.r-project.org/R/trunk@87938 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 3c96078 commit 7a5eddd

File tree

10 files changed

+66
-43
lines changed

10 files changed

+66
-43
lines changed

src/include/Rinternals.h

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ typedef struct SEXPREC *SEXP;
203203
#define CHAR(x) R_CHAR(x)
204204
const char *(R_CHAR)(SEXP x);
205205

206-
/* Various tests with macro versions in the internal headers */
206+
/* Various tests with macro versions in the internal headers such as Defn.h */
207207
Rboolean (Rf_isNull)(SEXP s);
208208
Rboolean (Rf_isSymbol)(SEXP s);
209209
Rboolean (Rf_isLogical)(SEXP s);
@@ -510,12 +510,12 @@ SEXP Rf_allocS4Object(void);
510510
SEXP Rf_allocSExp(SEXPTYPE);
511511
// next is not documented but generated by inlined calls to Rf_allocVector
512512
SEXP Rf_allocVector3(SEXPTYPE, R_xlen_t, R_allocator_t*);
513-
R_xlen_t Rf_any_duplicated(SEXP x, Rboolean from_last);
514-
R_xlen_t Rf_any_duplicated3(SEXP x, SEXP incomp, Rboolean from_last);
513+
R_xlen_t Rf_any_duplicated(SEXP x, Rboolean from_last); // unique.c
514+
R_xlen_t Rf_any_duplicated3(SEXP x, SEXP incomp, Rboolean from_last); // unique.c
515515
SEXP Rf_classgets(SEXP, SEXP);
516516
SEXP Rf_cons(SEXP, SEXP);
517-
void Rf_copyMatrix(SEXP, SEXP, Rboolean);
518-
void Rf_copyListMatrix(SEXP, SEXP, Rboolean);
517+
void Rf_copyMatrix(SEXP, SEXP, Rboolean); // duplicate.c
518+
void Rf_copyListMatrix(SEXP, SEXP, Rboolean); // duplicate.c
519519
void Rf_copyMostAttrib(SEXP, SEXP);
520520
void Rf_copyVector(SEXP, SEXP);
521521
void Rf_defineVar(SEXP, SEXP, SEXP);
@@ -527,15 +527,15 @@ SEXP R_duplicate_attr(SEXP);
527527
SEXP R_shallow_duplicate_attr(SEXP);
528528
SEXP Rf_lazy_duplicate(SEXP);
529529
/* the next really should not be here and is also in Defn.h */
530-
SEXP Rf_duplicated(SEXP, Rboolean);
530+
SEXP Rf_duplicated(SEXP, Rboolean); // duplicate.c
531531
SEXP Rf_eval(SEXP, SEXP);
532532
SEXP Rf_findFun(SEXP, SEXP);
533533
SEXP Rf_findVar(SEXP, SEXP);
534534
SEXP Rf_findVarInFrame(SEXP, SEXP);
535-
SEXP Rf_findVarInFrame3(SEXP, SEXP, Rboolean);
535+
SEXP Rf_findVarInFrame3(SEXP, SEXP, Rboolean); // envir.c
536536
Rboolean R_existsVarInFrame(SEXP, SEXP);
537-
SEXP R_getVar(SEXP, SEXP, Rboolean);
538-
SEXP R_getVarEx(SEXP, SEXP, Rboolean, SEXP);
537+
SEXP R_getVar(SEXP, SEXP, Rboolean); // envir.c
538+
SEXP R_getVarEx(SEXP, SEXP, Rboolean, SEXP); // envir.c
539539
void R_removeVarFromFrame(SEXP, SEXP);
540540
SEXP Rf_getAttrib(SEXP, SEXP);
541541
SEXP Rf_GetArrayDimnames(SEXP);
@@ -551,19 +551,19 @@ SEXP Rf_install(const char *);
551551
SEXP Rf_installChar(SEXP);
552552
SEXP Rf_installNoTrChar(SEXP);
553553
SEXP Rf_installTrChar(SEXP);
554-
Rboolean Rf_isOrdered(SEXP);
555-
Rboolean Rf_isUnordered(SEXP);
556-
Rboolean Rf_isUnsorted(SEXP, Rboolean);
557-
Rboolean R_isTRUE(SEXP);
554+
Rboolean Rf_isOrdered(SEXP); // util.c
555+
Rboolean Rf_isUnordered(SEXP); // util.c
556+
Rboolean Rf_isUnsorted(SEXP, Rboolean); // sort.c
557+
Rboolean R_isTRUE(SEXP); // util.c
558558
SEXP Rf_lengthgets(SEXP, R_len_t);
559559
SEXP Rf_xlengthgets(SEXP, R_xlen_t);
560-
SEXP R_lsInternal(SEXP, Rboolean);
561-
SEXP R_lsInternal3(SEXP, Rboolean, Rboolean);
560+
SEXP R_lsInternal(SEXP, Rboolean); // envir.c
561+
SEXP R_lsInternal3(SEXP, Rboolean, Rboolean); // envir.c
562562
SEXP Rf_match(SEXP, SEXP, int);
563563
SEXP Rf_namesgets(SEXP, SEXP);
564564
SEXP Rf_mkChar(const char *);
565565
SEXP Rf_mkCharLen(const char *, int);
566-
Rboolean Rf_NonNullStringMatch(SEXP, SEXP);
566+
Rboolean Rf_NonNullStringMatch(SEXP, SEXP); // match.c
567567
int Rf_ncols(SEXP);
568568
int Rf_nrows(SEXP);
569569
SEXP Rf_nthcdr(SEXP, int);
@@ -582,7 +582,7 @@ SEXP Rf_protect(SEXP);
582582
SEXP Rf_setAttrib(SEXP, SEXP, SEXP);
583583
void Rf_setVar(SEXP, SEXP, SEXP);
584584
SEXPTYPE Rf_str2type(const char *);
585-
Rboolean Rf_StringBlank(SEXP);
585+
Rboolean Rf_StringBlank(SEXP); // util.c
586586
SEXP Rf_substitute(SEXP,SEXP);
587587
SEXP Rf_topenv(SEXP, SEXP);
588588
const char * Rf_translateChar(SEXP);
@@ -608,8 +608,8 @@ SEXP R_tryEval(SEXP, SEXP, int *);
608608
SEXP R_tryEvalSilent(SEXP, SEXP, int *);
609609
SEXP R_GetCurrentEnv(void);
610610

611-
Rboolean Rf_isS4(SEXP);
612-
SEXP Rf_asS4(SEXP, Rboolean, int);
611+
Rboolean Rf_isS4(SEXP); // objects.c
612+
SEXP Rf_asS4(SEXP, Rboolean, int); // objects.c
613613
SEXP Rf_S3Class(SEXP);
614614
int Rf_isBasicClass(const char *);
615615

@@ -625,9 +625,9 @@ typedef enum {
625625
} cetype_t;
626626

627627
cetype_t Rf_getCharCE(SEXP);
628-
Rboolean Rf_charIsASCII(SEXP);
629-
Rboolean Rf_charIsUTF8(SEXP);
630-
Rboolean Rf_charIsLatin1(SEXP);
628+
Rboolean Rf_charIsASCII(SEXP); // sysutils.c
629+
Rboolean Rf_charIsUTF8(SEXP); // sysutils.c
630+
Rboolean Rf_charIsLatin1(SEXP); // sysutils.c
631631
SEXP Rf_mkCharCE(const char *, cetype_t);
632632
SEXP Rf_mkCharLenCE(const char *, int, cetype_t);
633633
const char *Rf_reEnc(const char *x, cetype_t ce_in, cetype_t ce_out, int subst);
@@ -655,15 +655,15 @@ DL_FUNC R_ExternalPtrAddrFn(SEXP s);
655655

656656
/* Finalization interface */
657657
typedef void (*R_CFinalizer_t)(SEXP);
658-
void R_RegisterFinalizer(SEXP s, SEXP fun);
659-
void R_RegisterCFinalizer(SEXP s, R_CFinalizer_t fun);
660-
void R_RegisterFinalizerEx(SEXP s, SEXP fun, Rboolean onexit);
661-
void R_RegisterCFinalizerEx(SEXP s, R_CFinalizer_t fun, Rboolean onexit);
658+
void R_RegisterFinalizer(SEXP s, SEXP fun);
659+
void R_RegisterCFinalizer(SEXP s, R_CFinalizer_t fun); // memory,c
660+
void R_RegisterFinalizerEx(SEXP s, SEXP fun, Rboolean onexit); // memory,c
661+
void R_RegisterCFinalizerEx(SEXP s, R_CFinalizer_t fun, Rboolean onexit); // memory,c
662662
void R_RunPendingFinalizers(void);
663663

664664
/* Weak reference interface */
665-
SEXP R_MakeWeakRef(SEXP key, SEXP val, SEXP fin, Rboolean onexit);
666-
SEXP R_MakeWeakRefC(SEXP key, SEXP val, R_CFinalizer_t fin, Rboolean onexit);
665+
SEXP R_MakeWeakRef(SEXP key, SEXP val, SEXP fin, Rboolean onexit); // memory,c
666+
SEXP R_MakeWeakRefC(SEXP key, SEXP val, R_CFinalizer_t fin, Rboolean onexit); // memory,c
667667
SEXP R_WeakRefKey(SEXP w);
668668
SEXP R_WeakRefValue(SEXP w);
669669
void R_RunWeakRefFinalizer(SEXP w);
@@ -673,7 +673,7 @@ SEXP R_ClosureExpr(SEXP);
673673
SEXP R_BytecodeExpr(SEXP e);
674674

675675
/* Protected evaluation */
676-
Rboolean R_ToplevelExec(void (*fun)(void *), void *data);
676+
Rboolean R_ToplevelExec(void (*fun)(void *), void *data); // context.c
677677
SEXP R_ExecWithCleanup(SEXP (*fun)(void *), void *data,
678678
void (*cleanfun)(void *), void *cleandata);
679679
SEXP R_tryCatch(SEXP (*)(void *), void *, /* body closure*/
@@ -688,25 +688,25 @@ SEXP R_MakeUnwindCont(void);
688688
NORET void R_ContinueUnwind(SEXP cont);
689689
SEXP R_UnwindProtect(SEXP (*fun)(void *data), void *data,
690690
void (*cleanfun)(void *data, Rboolean jump),
691-
void *cleandata, SEXP cont);
691+
void *cleandata, SEXP cont); // context.c
692692

693693
/* Environment and Binding Features */
694694
SEXP R_NewEnv(SEXP, int, int);
695-
Rboolean R_IsPackageEnv(SEXP rho);
695+
Rboolean R_IsPackageEnv(SEXP rho); // envir.c
696696
SEXP R_PackageEnvName(SEXP rho);
697697
SEXP R_FindPackageEnv(SEXP info);
698-
Rboolean R_IsNamespaceEnv(SEXP rho);
698+
Rboolean R_IsNamespaceEnv(SEXP rho); // envir.c
699699
SEXP R_NamespaceEnvSpec(SEXP rho);
700700
SEXP R_FindNamespace(SEXP info);
701701
void R_LockEnvironment(SEXP env, Rboolean bindings);
702-
Rboolean R_EnvironmentIsLocked(SEXP env);
702+
Rboolean R_EnvironmentIsLocked(SEXP env); // envir.c
703703
void R_LockBinding(SEXP sym, SEXP env);
704704
void R_unLockBinding(SEXP sym, SEXP env);
705705
void R_MakeActiveBinding(SEXP sym, SEXP fun, SEXP env);
706-
Rboolean R_BindingIsLocked(SEXP sym, SEXP env);
707-
Rboolean R_BindingIsActive(SEXP sym, SEXP env);
706+
Rboolean R_BindingIsLocked(SEXP sym, SEXP env); // envir.c
707+
Rboolean R_BindingIsActive(SEXP sym, SEXP env); // envir.c
708708
SEXP R_ActiveBindingFunction(SEXP sym, SEXP env);
709-
Rboolean R_HasFancyBindings(SEXP rho);
709+
Rboolean R_HasFancyBindings(SEXP rho); // envir.c
710710

711711

712712
/* ../main/errors.c : */
@@ -865,12 +865,15 @@ int R_system(const char *);
865865
#define IDENT_USE_CLOENV 16
866866
#define IDENT_USE_SRCREF 32
867867
#define IDENT_EXTPTR_AS_REF 64
868-
Rboolean R_compute_identical(SEXP, SEXP, int);
868+
Rboolean R_compute_identical(SEXP, SEXP, int); // identical.c
869869

870870
SEXP R_body_no_src(SEXP x); // body(x) without "srcref" etc, ../main/utils.c
871871

872872
/* C version of R's indx <- order(..., na.last, decreasing) :
873-
e.g. arglist = Rf_lang2(x,y) or Rf_lang3(x,y,z) */
873+
e.g. arglist = Rf_lang2(x,y) or Rf_lang3(x,y,z)
874+
875+
In sort.c
876+
*/
874877
void R_orderVector (int *indx, int n, SEXP arglist, Rboolean nalast, Rboolean decreasing);
875878
// C version of R's indx <- order(x, na.last, decreasing) :
876879
void R_orderVector1(int *indx, int n, SEXP x, Rboolean nalast, Rboolean decreasing);
@@ -1247,7 +1250,7 @@ void (SET_S4_OBJECT)(SEXP x); // used by Rcpp (not?) RTMB RcppInt64 data.table f
12471250
void (UNSET_S4_OBJECT)(SEXP x); // used by Rcpp (not?) collapse data.table essentials slam vctrs
12481251
const char *R_curErrorBuf(void); // used by Rserve gert unix
12491252
int (IS_SCALAR)(SEXP x, int type); // used by rbedrock symengine this.path
1250-
Rboolean Rf_psmatch(const char *, const char *, Rboolean); // used by rgl
1253+
Rboolean Rf_psmatch(const char *, const char *, Rboolean); // match.c, used by rgl
12511254

12521255
/* used in a couple of packages but should probably be dropped
12531256
error_return: grr nanonext rJava rbedrock

src/main/character.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ attribute_hidden SEXP do_nzchar(SEXP call, SEXP op, SEXP args, SEXP env)
157157
-2 ... the quantity is not computable (bytes encoding)
158158
semi-internal buffer cbuff is never freed, should be freed by caller
159159
*/
160+
// in Rinternals.h
160161
int R_nchar(SEXP string, nchar_type type_,
161162
Rboolean allowNA, Rboolean keepNA, const char* msg_name)
162163
{

src/main/duplicate.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ attribute_hidden void reset_duplicate_counter(void)
130130
}
131131
#endif
132132

133+
// In Rinternals.h
133134
SEXP duplicate(SEXP s){
134135
SEXP t;
135136

@@ -405,6 +406,7 @@ void copyVector(SEXP s, SEXP t)
405406
}
406407
}
407408

409+
// In Rinternals.h
408410
void copyListMatrix(SEXP s, SEXP t, Rboolean byrow)
409411
{
410412
int nr = nrows(s), nc = ncols(s);
@@ -440,6 +442,7 @@ static R_INLINE SEXP VECTOR_ELT_LD(SEXP x, R_xlen_t i)
440442
return lazy_duplicate(VECTOR_ELT(x, i));
441443
}
442444

445+
// In Rinternals.h
443446
void copyMatrix(SEXP s, SEXP t, Rboolean byrow)
444447
{
445448
int nr = nrows(s), nc = ncols(s);

src/main/envir.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@ void R_SetVarLocValue(R_varloc_t vl, SEXP value)
991991
symbol in this frame (FALSE). This is used for get() and exists().
992992
*/
993993

994+
// In Rinternals.h
994995
SEXP findVarInFrame3(SEXP rho, SEXP symbol, Rboolean doGet)
995996
{
996997
int hashcode;
@@ -2280,6 +2281,7 @@ attribute_hidden SEXP do_mget(SEXP call, SEXP op, SEXP args, SEXP rho)
22802281
return(ans);
22812282
}
22822283

2284+
// In Rinternals.h
22832285
SEXP R_getVarEx(SEXP sym, SEXP rho, Rboolean inherits, SEXP ifnotfound)
22842286
{
22852287
if (TYPEOF(sym) != SYMSXP)
@@ -2300,6 +2302,7 @@ SEXP R_getVarEx(SEXP sym, SEXP rho, Rboolean inherits, SEXP ifnotfound)
23002302
return val;
23012303
}
23022304

2305+
// In Rinternals.h
23032306
SEXP R_getVar(SEXP sym, SEXP rho, Rboolean inherits)
23042307
{
23052308
SEXP val = R_getVarEx(sym, rho, inherits, R_UnboundValue);
@@ -2940,6 +2943,7 @@ attribute_hidden SEXP do_ls(SEXP call, SEXP op, SEXP args, SEXP rho)
29402943

29412944
/* takes an environment, a boolean indicating whether to get all
29422945
names and a boolean if sorted is desired */
2946+
// In Rinternals.h
29432947
SEXP R_lsInternal3(SEXP env, Rboolean all, Rboolean sorted)
29442948
{
29452949
if(IS_USER_DATABASE(env)) {
@@ -2980,6 +2984,7 @@ SEXP R_lsInternal3(SEXP env, Rboolean all, Rboolean sorted)
29802984
}
29812985

29822986
/* non-API version used in several packages */
2987+
// in Rinternals.h
29832988
SEXP R_lsInternal(SEXP env, Rboolean all)
29842989
{
29852990
return R_lsInternal3(env, all, TRUE);

src/main/match.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646

4747

4848
/* used in subscript.c and subassign.c */
49+
// In Rinternals.h
4950
Rboolean NonNullStringMatch(SEXP s, SEXP t)
5051
{
5152
/* "" or NA string matches nothing */

src/main/objects.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1835,12 +1835,13 @@ SEXP R_get_primname(SEXP object)
18351835
}
18361836
#endif
18371837

1838-
1838+
// in Rinternals.h
18391839
Rboolean isS4(SEXP s)
18401840
{
18411841
return IS_S4_OBJECT(s);
18421842
}
18431843

1844+
// in Rinternals.h
18441845
SEXP asS4(SEXP s, Rboolean flag, int complete)
18451846
{
18461847
if(flag == IS_S4_OBJECT(s))

src/main/sort.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ GREATER_2_SUB_DEF(intdbl2greater, int, double, icmp, rcmp)
11201120
* to the API */
11211121

11221122
// Usage: R_orderVector(indx, n, Rf_lang2(x,y), nalast, decreasing)
1123-
// API
1123+
// In Rinternals.h
11241124
void R_orderVector(int *indx, // must be pre-allocated to length >= n
11251125
int n,
11261126
SEXP arglist, // <- e.g. Rf_lang2(x,y)
@@ -1133,7 +1133,7 @@ void R_orderVector(int *indx, // must be pre-allocated to length >= n
11331133
}
11341134

11351135
// Fast version of 1-argument case of R_orderVector()
1136-
// API
1136+
// In Rinternals.h
11371137
void R_orderVector1(int *indx, int n, SEXP x,
11381138
Rboolean nalast, Rboolean decreasing)
11391139
{

src/main/sysutils.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,12 +951,14 @@ cetype_t getCharCE(SEXP x)
951951
else return CE_NATIVE;
952952
}
953953

954+
// In Rinternals.h
954955
Rboolean charIsASCII(SEXP x)
955956
{
956957
CHECK_CHARSXP(x);
957958
return IS_ASCII(x) ? TRUE : FALSE;
958959
}
959960

961+
// In Rinternals.h
960962
Rboolean charIsUTF8(SEXP x)
961963
{
962964
CHECK_CHARSXP(x);
@@ -966,6 +968,7 @@ Rboolean charIsUTF8(SEXP x)
966968
return TRUE;
967969
}
968970

971+
// In Rinternals.h
969972
Rboolean charIsLatin1(SEXP x)
970973
{
971974
CHECK_CHARSXP(x);

src/main/unique.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ static SEXP Duplicated(SEXP x, Rboolean from_last, int nmax)
861861
return ans;
862862
}
863863

864+
//In Rinternals.h
864865
attribute_hidden R_xlen_t sorted_any_duplicated(SEXP x, Rboolean from_last) {
865866
int itmp, sorted;
866867
double rtmp;
@@ -977,6 +978,7 @@ attribute_hidden R_xlen_t sorted_any_duplicated(SEXP x, Rboolean from_last) {
977978
#undef SORTED_ANYDUP_NANS
978979

979980
/* simpler version of the above : return 1-based index of first, or 0 : */
981+
// In Rinternals.h
980982
R_xlen_t any_duplicated(SEXP x, Rboolean from_last)
981983
{
982984
R_xlen_t result = 0;

src/main/util.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,20 +181,23 @@ SEXP asChar(SEXP x)
181181
return NA_STRING;
182182
}
183183

184+
// In Rinternals.h
184185
Rboolean isUnordered(SEXP s)
185186
{
186187
return (TYPEOF(s) == INTSXP
187188
&& inherits(s, "factor")
188189
&& !inherits(s, "ordered"));
189190
}
190191

192+
// In Rinternals.h
191193
Rboolean isOrdered(SEXP s)
192194
{
193195
return (TYPEOF(s) == INTSXP
194196
&& inherits(s, "factor")
195197
&& inherits(s, "ordered"));
196198
}
197199

200+
// In Rinternals.h
198201
Rboolean R_isTRUE(SEXP x)
199202
{
200203
if (TYPEOF(x) == LGLSXP && XLENGTH(x) == 1) {
@@ -448,7 +451,7 @@ size_t mbcsToUcs2(const char *in, R_ucs2_t *out, int nout, int enc)
448451

449452
#include <wctype.h>
450453

451-
// non-API put used in the internet module and in packages
454+
// non-API but used in the internet module and in packages
452455
Rboolean isBlankString(const char *s)
453456
{
454457
if(mbcslocale) {
@@ -465,6 +468,7 @@ Rboolean isBlankString(const char *s)
465468
return TRUE;
466469
}
467470

471+
// in Rinternals.h
468472
Rboolean StringBlank(SEXP x)
469473
{
470474
if (x == R_NilValue) return TRUE;

0 commit comments

Comments
 (0)