Skip to content

Commit

Permalink
patch from Martin Maechler
Browse files Browse the repository at this point in the history
  • Loading branch information
t-kalinowski committed Jul 27, 2023
1 parent d65253a commit e742aa1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/include/Rinternals.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ typedef unsigned int SEXPTYPE;
#define EXTPTRSXP 22 /* external pointer */
#define WEAKREFSXP 23 /* weak reference */
#define RAWSXP 24 /* raw bytes */
#define OBJSXP 25 /* Object, non-vector */
#define S4SXP 25 /* Same as OBJSXP, name retained for backwards compatability */
#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
9 changes: 4 additions & 5 deletions src/main/coerce.c
Original file line number Diff line number Diff line change
Expand Up @@ -1955,11 +1955,10 @@ Rcomplex asComplex(SEXP x)
attribute_hidden SEXP do_typeof(SEXP call, SEXP op, SEXP args, SEXP rho)
{
checkArity(op, args);
SEXP x = CAR(args);
if(TYPEOF(x) == OBJSXP && !IS_S4_OBJECT(x))
return mkString("object");
else
return type2rstr(TYPEOF(x));
if(TYPEOF(CAR(args)) == OBJSXP && !IS_S4_OBJECT(CAR(args)))
return mkString("object");
else
return type2rstr(TYPEOF(CAR(args)));
}

/* Define many of the <primitive> "is.xxx" functions :
Expand Down
2 changes: 1 addition & 1 deletion src/main/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const char *sexptype2char(SEXPTYPE type) {
case BCODESXP: return "BCODESXP";
case EXTPTRSXP: return "EXTPTRSXP";
case WEAKREFSXP: return "WEAKREFSXP";
case OBJSXP: return "OBJSXP";
case OBJSXP: return "OBJSXP"; /* was S4SXP */
case RAWSXP: return "RAWSXP";
case NEWSXP: return "NEWSXP"; /* should never happen */
case FREESXP: return "FREESXP";
Expand Down
20 changes: 10 additions & 10 deletions src/main/print.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* R : A Computer Language for Statistical Data Analysis
* Copyright (C) 2000-2022 The R Core Team.
* Copyright (C) 2000-2023 The R Core Team.
* Copyright (C) 1995-1998 Robert Gentleman and Ross Ihaka.
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -968,15 +968,15 @@ attribute_hidden void PrintValueRec(SEXP s, R_PrintData *data)
Rprintf("<weak reference>\n");
break;
case OBJSXP:
if(IS_S4_OBJECT(s)) {
/* we got here because no show method, usually no class.
Print the "slots" as attributes, since we don't know the class.
*/
Rprintf("<S4 Type Object>\n");
} else {
/* OBJSXP type, S4 obj bit not set*/
Rprintf("<object>\n");
}
if(IS_S4_OBJECT(s)) {
/* we got here because no show method, usually no class.
Print the "slots" as attributes, since we don't know the class.
*/
Rprintf("<S4 Type Object>\n");
} else {
/* OBJSXP type, S4 obj bit not set*/
Rprintf("<object>\n");
}
break;
default:
UNIMPLEMENTED_TYPE("PrintValueRec", s);
Expand Down
4 changes: 4 additions & 0 deletions src/main/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ TypeTable[] = {
{ "weakref", WEAKREFSXP },
{ "raw", RAWSXP },
{ "S4", S4SXP },
{ "object", OBJSXP }, /* == S4SXP */
/* aliases : */
{ "numeric", REALSXP },
{ "name", SYMSXP },
Expand All @@ -234,6 +235,9 @@ SEXPTYPE str2type(const char *s)
if (!strcmp(s, TypeTable[i].str))
return (SEXPTYPE) TypeTable[i].type;
}
if (!strcmp(s, "object"))
return (SEXPTYPE) OBJSXP;

/* SEXPTYPE is an unsigned int, so the compiler warns us w/o the cast. */
return (SEXPTYPE) -1;
}
Expand Down

0 comments on commit e742aa1

Please sign in to comment.