Skip to content

Commit d92f65f

Browse files
author
luke
committed
Add R_class function.
git-svn-id: https://svn.r-project.org/R/trunk@89095 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 40922bb commit d92f65f

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

doc/NEWS.Rd

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,20 @@
233233
\code{SET_FORMALS}, \code{SET_BODY}, \code{SET_CLOENV},
234234
\code{STRING_PTR}, \code{DATAPTR}, \code{XTRUELENGTH},
235235
\code{R_duplicate_attr}, \code{R_shallow_duplicate_attr},
236-
\code{getConnection}, \code{LEVELS}, \code{SETLEVELS}.
236+
\code{getConnection}, \code{LEVELS}, \code{SETLEVELS},
237+
\code{R_data_class}.
237238
238239
\item The deprecated macros \code{CHARACTER_DATA} and
239240
\code{CHARACTER_POINTER} now return \code{const} pointers since using
240241
writable pointers in packages is not safe.
241242
242-
\item New function \code{DATAPTR_RW} for use in implementing
243+
\item New function \code{DATAPTR_RW()} for use in implementing
243244
\code{ALTREP} \code{Dataptr} methods. This function should not be
244245
used in any other contexts.
245246
247+
\item New function \code{R_class()} as the \code{C} equivalent of
248+
\code{class()} in \R.
249+
246250
\item The non-API header files \file{R_ext/Callbacks.h} and
247251
\file{R_ext/PrtUtil.h} are no longer copied to the installed
248252
includes directory.

doc/manual/R-exts.texi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13022,6 +13022,11 @@ As the value is a character vector, we have to know how to create that
1302213022
from a C character array, which we do using the function
1302313023
@code{Rf_mkChar}.
1302413024

13025+
Objects without an explicit class can have an implicit class. In @R{}
13026+
the function @code{class} returns the explicit or implicit class. The
13027+
function @code{R_class} is the @code{C} equivalent.
13028+
@apifun R_class
13029+
1302513030
@node S4 objects
1302613031
@subsection S4 objects
1302713032
@cindex S4 objects
@@ -17602,6 +17607,8 @@ functions that should be used instead:
1760217607
an argument to your C function.
1760317608
@item SETLENGTH
1760417609
See @ref{Resizing vectors}.
17610+
@item R_data_class
17611+
Use @code{R_class} added in @R{} 4.6.0
1760517612
@end table
1760617613

1760717614
For recently added entry points packages that need to be compiled
@@ -17810,6 +17817,7 @@ void CLEAR_ATTRIB(SEXP x)
1781017817

1781117818
#if R_VERSION < R_Version(4, 6, 0)
1781217819
# define DATAPTR_RW(x) DATAPTR(x)
17820+
# define R_class(x) R_data_class(x, FALSE)
1781317821
# define R_allocResizableVector(type, maxlen) Rf_allocVector(type, naxlen)
1781417822
# define R_duplicateAsResizable(x) duplicate(x)
1781517823
# define R_resizeVector(x, newlen) SETLENGTH(x, n)

src/include/Rinternals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ SEXP Rf_allocSExp(SEXPTYPE);
512512
//SEXP Rf_allocVector3(SEXPTYPE, R_xlen_t, R_allocator_t*);
513513
R_xlen_t Rf_any_duplicated(SEXP x, Rboolean from_last); // unique.c
514514
R_xlen_t Rf_any_duplicated3(SEXP x, SEXP incomp, Rboolean from_last); // unique.c
515+
SEXP R_class(SEXP);
515516
SEXP Rf_classgets(SEXP, SEXP);
516517
SEXP Rf_cons(SEXP, SEXP);
517518
void Rf_copyMatrix(SEXP, SEXP, Rboolean); // duplicate.c

src/library/tools/R/sotools.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ warnNonAPI <-
747747
"OBJECT", "SET_TYPEOF", "ENVFLAGS", "SET_ENVFLAGS", "SET_FORMALS",
748748
"SET_BODY", "SET_CLOENV", "STRING_PTR", "DATAPTR", "XTRUELENGTH",
749749
"R_shallow_duplicate_attr", "R_duplicate_attr", "getConnection",
750-
"LEVELS", "SETLEVELS")
750+
"LEVELS", "SETLEVELS", "R_data_class")
751751

752752
## grDevices uses R_Home R_InputHandlers R_TempDir R_Visible R_cairoCdynload R_fopen R_gzclose R_gzgets R_gzopen R_isForkedChild Rf_envlength Rf_strIsASCII Rf_utf8towcs Rg_set_col_ptrs Ri18n_wcwidth addInputHandler do_X11 do_contourLines do_getGraphicsEventEnv do_getSnapshot do_playSnapshot do_saveplot locale2charset mbcsToUcs2 ptr_R_ProcessEvents
753753

src/main/attrib.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,9 @@ attribute_hidden SEXP R_do_data_class(SEXP call, SEXP op, SEXP args, SEXP env)
908908
return R_data_class(CAR(args), FALSE);
909909
}
910910

911+
// C version of class()
912+
SEXP R_class(SEXP x) { return R_data_class(x, FALSE); }
913+
911914
/* names(object) <- name */
912915
attribute_hidden SEXP do_namesgets(SEXP call, SEXP op, SEXP args, SEXP env)
913916
{

0 commit comments

Comments
 (0)