Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define OBJSXP #128

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2566465
define OBJSXP
t-kalinowski Jun 7, 2023
34403ee
ad-hoc OBJSXP constructor (for testing)
t-kalinowski Jun 7, 2023
582d246
swap some `TYPEOF(S4SXP)` with `IS_S4_OBJECT()`
t-kalinowski Jun 7, 2023
59fef7e
update print.c
t-kalinowski Jun 7, 2023
3035395
update dput() for OBJSXP
t-kalinowski Jun 7, 2023
5be92e1
rename `.new_object` -> `object`
t-kalinowski Jun 7, 2023
341d870
checkin stray 'object' rename
t-kalinowski Jun 7, 2023
a4d81b6
Add `object()` closure to base namespace
t-kalinowski Jun 7, 2023
54a1efc
comment / TODO
t-kalinowski Jun 7, 2023
ffa2e67
make `dput()` actually useful for `object()`
t-kalinowski Jun 7, 2023
d3192c0
prefer `attributes<-` over `structure()`
t-kalinowski Jun 7, 2023
32689c7
update `typeof()`
t-kalinowski Jun 7, 2023
a47a1a3
update inspect()
t-kalinowski Jun 8, 2023
9eea346
revert updating checks in S4
t-kalinowski Jun 8, 2023
6f61944
use `OBJSXP` instead of `S4SXP` for clarity
t-kalinowski Jun 8, 2023
279e86f
cosmetic
t-kalinowski Jun 8, 2023
2657ca3
comment out `object()` constructor
t-kalinowski Jun 8, 2023
d65253a
Merge branch 'master' into rename-s4sxp
t-kalinowski Jul 26, 2023
e742aa1
patch from Martin Maechler
t-kalinowski Jul 27, 2023
d7ae4f9
Merge remote-tracking branch 'upstream/master' into rename-s4sxp
t-kalinowski Jul 27, 2023
46ee166
updated patch from Martin
t-kalinowski Jul 28, 2023
33a105f
update `type2char()`
t-kalinowski Jul 31, 2023
4883a6b
type2char() usage comments
t-kalinowski Jul 31, 2023
145626b
update type2str() usage
t-kalinowski Jul 31, 2023
8dad2ac
Merge remote-tracking branch 'upstream/master' into rename-s4sxp
t-kalinowski Jul 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@
argument descriptions when they spanned multiple lines,
including those generated by \code{prompt()}.
These cases are now noted by \command{R CMD check}.

\item Communication between parent and child processes in
\code{multicore} part of \code{parallel} could fail on platforms
that do not support arbitrarily large payload in system functions
\code{read()}/\code{write()} on pipes (seen on macOS). The payload
is now split into 1Gb chunks to avoid that problem. \PR{18571}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/include/Rinlinedfuns.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* R : A Computer Language for Statistical Data Analysis
* Copyright (C) 1999--2023 The R Core Team.
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
* Copyright (C) 1999-2017 The R Core Team.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -108,7 +108,7 @@ INLINE_FUN void CHKVEC(SEXP x) {
case WEAKREFSXP:
break;
default:
error("cannot get data pointer of '%s' objects", type2char(TYPEOF(x)));
error("cannot get data pointer of '%s' objects", R_typeToChar(x));
}
}
#else
Expand Down
7 changes: 6 additions & 1 deletion src/include/Rinternals.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ typedef unsigned int SEXPTYPE;
#define EXTPTRSXP 22 /* external pointer */
#define WEAKREFSXP 23 /* weak reference */
#define RAWSXP 24 /* raw bytes */
#define S4SXP 25 /* S4, non-vector */
#define OBJSXP 25 /* object, non-vector */
#define S4SXP 25 /* same as OBJSXP, retained for back compatability */

/* used for detecting PROTECT issues in memory.c */
#define NEWSXP 30 /* fresh node created in new page */
Expand Down Expand Up @@ -561,6 +562,10 @@ SEXP Rf_topenv(SEXP, SEXP);
const char * Rf_translateChar(SEXP);
const char * Rf_translateCharUTF8(SEXP);
const char * Rf_type2char(SEXPTYPE);
const char * R_typeToChar(SEXP);
#ifdef USE_TYPE2CHAR_2
const char * R_typeToChar2(SEXP, SEXPTYPE);
#endif
SEXP Rf_type2rstr(SEXPTYPE);
SEXP Rf_type2str(SEXPTYPE);
SEXP Rf_type2str_nowarn(SEXPTYPE);
Expand Down
2 changes: 1 addition & 1 deletion src/library/methods/src/methods_list_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static SEXP R_conditionMessage(SEXP cond)
/* Type check return value so callers can safely extract a C string */
if (TYPEOF(out) != STRSXP)
error(_("unexpected type '%s' for condition message"),
type2char(TYPEOF(out)));
R_typeToChar(out));
if (length(out) != 1)
error(_("condition message must be length 1"));

Expand Down
10 changes: 5 additions & 5 deletions src/library/stats/src/complete_cases.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ SEXP compcases(SEXP args)
goto bad;
}
else
error(R_MSG_type, type2char(TYPEOF(CAR(t))));
error(R_MSG_type, R_typeToChar(CAR(t)));
}
/* FIXME : Need to be careful with the use of isVector() */
/* since this includes lists and expressions. */
Expand Down Expand Up @@ -113,7 +113,7 @@ SEXP compcases(SEXP args)
goto bad;
}
else
error(R_MSG_type, type2char(TYPEOF(CAR(s))));
error(R_MSG_type, R_typeToChar(CAR(s)));
}

if (len < 0)
Expand Down Expand Up @@ -151,7 +151,7 @@ SEXP compcases(SEXP args)
break;
default:
UNPROTECT(1);
error(R_MSG_type, type2char(TYPEOF(u)));
error(R_MSG_type, R_typeToChar(u));
}
}
}
Expand Down Expand Up @@ -183,7 +183,7 @@ SEXP compcases(SEXP args)
break;
default:
UNPROTECT(1);
error(R_MSG_type, type2char(TYPEOF(u)));
error(R_MSG_type, R_typeToChar(u));
}
}
}
Expand Down Expand Up @@ -211,7 +211,7 @@ SEXP compcases(SEXP args)
break;
default:
UNPROTECT(1);
error(R_MSG_type, type2char(TYPEOF(u)));
error(R_MSG_type, R_typeToChar(u));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/library/stats/src/deriv.c
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ SEXP doD(SEXP args)
if (isExpression(CAR(args))) expr = VECTOR_ELT(CAR(args), 0);
else expr = CAR(args);
if (!(isLanguage(expr) || isSymbol(expr) || isNumeric(expr) || isComplex(expr)))
error(_("expression must not be type '%s'"), type2char(TYPEOF(expr)));
error(_("expression must not be type '%s'"), R_typeToChar(expr));
SEXP var = CADR(args);
if (!isString(var) || length(var) < 1)
error(_("variable must be a character string"));
Expand Down
4 changes: 2 additions & 2 deletions src/library/stats/src/model.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ SEXP modelframe(SEXP call, SEXP op, SEXP args, SEXP rho)
break;
default:
error(_("invalid type (%s) for variable '%s'"),
type2char(TYPEOF(ans)),
R_typeToChar(ans),
translateChar(STRING_ELT(names, i)));
}
if (nrows(ans) != nr)
Expand Down Expand Up @@ -667,7 +667,7 @@ SEXP modelmatrix(SEXP call, SEXP op, SEXP args, SEXP rho)
}
} else
error(_("variables of type '%s' are not allowed in model matrices"),
type2char(TYPEOF(var_i)));
R_typeToChar(var_i));
indx /= ll;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/library/utils/R/str.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# File src/library/utils/R/str.R
# Part of the R package, https://www.R-project.org
#
# Copyright (C) 1995-2021 The R Core Team
# Copyright (C) 1995-2023 The R Core Team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -474,7 +474,7 @@ str.default <-
)
}
} else if(typeof(object) %in%
c("externalptr", "weakref", "environment", "bytecode")) {
c("externalptr", "weakref", "environment", "bytecode", "object")) {
## Careful here, we don't want to change pointer objects
if(has.class)
cat(pClass(cl))
Expand Down
2 changes: 1 addition & 1 deletion src/main/RNG.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ static Rboolean GetRNGkind(SEXP seeds)
if (seeds == R_MissingArg) /* How can this happen? */
error(_("'.Random.seed' is a missing argument with no default"));
warning(_("'.Random.seed' is not an integer vector but of type '%s', so ignored"),
type2char(TYPEOF(seeds)));
R_typeToChar(seeds));
goto invalid;
}
is = INTEGER(seeds);
Expand Down
2 changes: 1 addition & 1 deletion src/main/altclasses.c
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ static Rboolean mmap_Inspect(SEXP x, int pre, int deep, int pvec,
Rboolean ptrOK = MMAP_PTROK(x);
Rboolean wrtOK = MMAP_WRTOK(x);
Rboolean serOK = MMAP_SEROK(x);
Rprintf(" mmaped %s", type2char(TYPEOF(x)));
Rprintf(" mmaped %s", R_typeToChar(x));
Rprintf(" [ptr=%d,wrt=%d,ser=%d]\n", ptrOK, wrtOK, serOK);
return TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ attribute_hidden SEXP do_vapply(SEXP call, SEXP op, SEXP args, SEXP rho)
commonType != INTSXP && commonType != LGLSXP &&
commonType != RAWSXP && commonType != STRSXP &&
commonType != VECSXP)
error(_("type '%s' is not supported"), type2char(commonType));
error(_("type '%s' is not supported"), R_typeToChar(value));
dim_v = getAttrib(value, R_DimSymbol);
array_value = (TYPEOF(dim_v) == INTSXP && LENGTH(dim_v) >= 1);
PROTECT(ans = allocVector(commonType, n*commonLen));
Expand Down Expand Up @@ -187,7 +187,7 @@ attribute_hidden SEXP do_vapply(SEXP call, SEXP op, SEXP args, SEXP rho)
}
if (!okay)
error(_("values must be type '%s',\n but FUN(X[[%d]]) result is type '%s'"),
type2char(commonType), i+1, type2char(valType));
R_typeToChar(value), i+1, R_typeToChar(val));
REPROTECT(val = coerceVector(val, commonType), indx);
}
/* Take row names from the first result only */
Expand Down
4 changes: 2 additions & 2 deletions src/main/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ attribute_hidden SEXP do_matrix(SEXP call, SEXP op, SEXP args, SEXP rho)
break;
default:
error(_("'data' must be of a vector type, was '%s'"),
type2char(TYPEOF(vals)));
R_typeToChar(vals));
}
lendat = XLENGTH(vals);
snr = CAR(args); args = CDR(args);
Expand Down Expand Up @@ -2071,7 +2071,7 @@ attribute_hidden SEXP do_array(SEXP call, SEXP op, SEXP args, SEXP rho)
break;
default:
error(_("'data' must be of a vector type, was '%s'"),
type2char(TYPEOF(vals)));
R_typeToChar(vals));
}
lendat = XLENGTH(vals);
dims = CADR(args);
Expand Down
14 changes: 7 additions & 7 deletions src/main/attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static SEXP row_names_gets(SEXP vec, SEXP val)
}
} else if(!isString(val))
error(_("row names must be 'character' or 'integer', not '%s'"),
type2char(TYPEOF(val)));
R_typeToChar(val));
PROTECT(vec);
PROTECT(val);
ans = installAttrib(vec, R_RowNamesSymbol, val);
Expand Down Expand Up @@ -135,7 +135,7 @@ attribute_hidden SEXP getAttrib0(SEXP vec, SEXP name)
}
else
error(_("getAttrib: invalid type (%s) for TAG"),
type2char(TYPEOF(TAG(vec))));
R_typeToChar(TAG(vec)));
}
UNPROTECT(1);
if (any) {
Expand Down Expand Up @@ -401,7 +401,7 @@ static void checkNames(SEXP x, SEXP s)
if (isVector(x) || isList(x) || isLanguage(x)) {
if (!isVector(s) && !isList(s))
error(_("invalid type (%s) for 'names': must be vector or NULL"),
type2char(TYPEOF(s)));
R_typeToChar(s));
if (xlength(x) != xlength(s))
error(_("'names' attribute [%d] must be the same length as the vector [%d]"), length(s), length(x));
}
Expand Down Expand Up @@ -1011,7 +1011,7 @@ SEXP namesgets(SEXP vec, SEXP val)
installAttrib(vec, R_NamesSymbol, val);
else
error(_("invalid type (%s) to set 'names' attribute"),
type2char(TYPEOF(vec)));
R_typeToChar(vec));
UNPROTECT(2);
return vec;
}
Expand Down Expand Up @@ -1131,7 +1131,7 @@ SEXP dimnamesgets(SEXP vec, SEXP val)
if (_this != R_NilValue) {
if (!isVector(_this))
error(_("invalid type (%s) for 'dimnames' (must be a vector)"),
type2char(TYPEOF(_this)));
R_typeToChar(_this));
if (INTEGER(dims)[i] != LENGTH(_this) && LENGTH(_this) != 0)
error(_("length of 'dimnames' [%d] not equal to array extent"),
i+1);
Expand Down Expand Up @@ -1169,7 +1169,7 @@ attribute_hidden SEXP do_dimnames(SEXP call, SEXP op, SEXP args, SEXP env)
}

SEXP R_dim(SEXP call, SEXP op, SEXP args, SEXP env)
{
{
SEXP ans;
/* DispatchOrEval internal generic: dim */
if (DispatchOrEval(call, op, "dim", args, env, &ans, 0, /* argsevald: */ 1))
Expand Down Expand Up @@ -1597,7 +1597,7 @@ attribute_hidden SEXP do_attrgets(SEXP call, SEXP op, SEXP args, SEXP env)
}
else {
error(_("invalid type '%s' for slot name"),
type2char(TYPEOF(nlist)));
R_typeToChar(nlist));
return R_NilValue; /*-Wall*/
}

Expand Down
16 changes: 9 additions & 7 deletions src/main/bind.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ LogicalAnswer(SEXP x, struct BindData *data, SEXP call)
break;
default:
errorcall(call, _("type '%s' is unimplemented in '%s'"),
type2char(TYPEOF(x)), "LogicalAnswer");
R_typeToChar(x), "LogicalAnswer");
}
}

Expand Down Expand Up @@ -329,7 +329,7 @@ IntegerAnswer(SEXP x, struct BindData *data, SEXP call)
break;
default:
errorcall(call, _("type '%s' is unimplemented in '%s'"),
type2char(TYPEOF(x)), "IntegerAnswer");
R_typeToChar(x), "IntegerAnswer");
}
}

Expand Down Expand Up @@ -378,7 +378,7 @@ RealAnswer(SEXP x, struct BindData *data, SEXP call)
break;
default:
errorcall(call, _("type '%s' is unimplemented in '%s'"),
type2char(TYPEOF(x)), "RealAnswer");
R_typeToChar(x), "RealAnswer");
}
}

Expand Down Expand Up @@ -451,7 +451,7 @@ ComplexAnswer(SEXP x, struct BindData *data, SEXP call)

default:
errorcall(call, _("type '%s' is unimplemented in '%s'"),
type2char(TYPEOF(x)), "ComplexAnswer");
R_typeToChar(x), "ComplexAnswer");
}
}

Expand Down Expand Up @@ -479,7 +479,7 @@ RawAnswer(SEXP x, struct BindData *data, SEXP call)
break;
default:
errorcall(call, _("type '%s' is unimplemented in '%s'"),
type2char(TYPEOF(x)), "RawAnswer");
R_typeToChar(x), "RawAnswer");
}
}

Expand Down Expand Up @@ -1162,8 +1162,8 @@ attribute_hidden SEXP do_bind(SEXP call, SEXP op, SEXP args, SEXP env)
to an expression is not ideal.
FIXME? had cbind(y ~ x, 1) work using lists, before */
default:
error(_("cannot create a matrix from type '%s'"),
type2char(mode));
error(_("cannot create a matrix from type '%s'"),
type2char(mode)); /* mode can only be EXPRSXP here */
}

if (PRIMVAL(op) == 1)
Expand Down Expand Up @@ -1396,6 +1396,8 @@ static SEXP cbind(SEXP call, SEXP args, SEXPTYPE mode, SEXP rho,
});
} else
/* not sure this can be reached, but to be safe: */
/* `mode` is created in do_bind(), it can only be one of the following:
NILSXP, LGLSXP, INTSXP, REALSXP, CPLXSXP, STRSXP, VECSXP, RAWSXP */
error(_("cannot create a matrix of type '%s'"),
type2char(mode));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ attribute_hidden SEXP do_cat(SEXP call, SEXP op, SEXP args, SEXP rho)
#endif
else
error(_("argument %d (type '%s') cannot be handled by 'cat'"),
1+iobj, type2char(TYPEOF(s)));
1+iobj, R_typeToChar(s));
/* FIXME : cat(...) should handle ANYTHING */
size_t w = strlen(p);
cat_sepwidth(sepr, &sepw, ntot);
Expand Down
Loading
Loading