Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2026-01-23 Dirk Eddelbuettel <edd@debian.org>

* inst/include/Rcpp/DataFrame.h (nrow): Use R_nrow() with R >= 4.6.0
* inst/include/Rcpp/proxy/AttributeProxy.h (attributeNames): Use
R_getAttribNames() with R >= 4.6.0;
* inst/include/Rcpp/proxy/AttributeProxy.h (hasAttribute): Use
R_hasAttrib with R >= 4.6.0

2026-01-22 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Roll micro version and date
Expand Down
9 changes: 6 additions & 3 deletions inst/include/Rcpp/DataFrame.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
//

// DataFrame.h: Rcpp R/C++ interface class library -- data frames
//
// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2010 - 2026 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
Expand Down Expand Up @@ -67,8 +66,12 @@ namespace Rcpp{
// discussed in #1430 is also possible and preferable. We also switch
// to returning R_xlen_t which as upcast from int is safe
inline R_xlen_t nrow() const {
#if R_VERSION < R_Version(4,6,0)
Shield<SEXP> rn{Rf_getAttrib(Parent::get__(), R_RowNamesSymbol)};
return Rf_xlength(rn);
#else
return R_nrow(Parent::get__());
#endif
}

template <typename T>
Expand Down
16 changes: 9 additions & 7 deletions inst/include/Rcpp/proxy/AttributeProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ class AttributeProxyPolicy {
std::vector<std::string> attributeNames() const {
std::vector<std::string> v;
#if R_VERSION >= R_Version(4, 6, 0)
auto visitor = [](SEXP name, SEXP attr, void* data) -> SEXP {
std::vector<std::string>* ptr = static_cast<std::vector<std::string>*>(data);
std::string s{CHAR(Rf_asChar(name))};
ptr->push_back(s);
return NULL;
};
R_mapAttrib(static_cast<const CLASS&>(*this).get__(), visitor, static_cast<void*>(&v));
SEXP attrs = R_getAttribNames( static_cast<const CLASS&>(*this));
R_xlen_t n = XLENGTH(attrs);
for (R_xlen_t i = 0; i < n; i++) {
v.push_back(std::string(CHAR(STRING_ELT(attrs, i))));
}
#else
SEXP attrs = ATTRIB( static_cast<const CLASS&>(*this).get__());
while( attrs != R_NilValue ){
Expand All @@ -98,7 +96,11 @@ class AttributeProxyPolicy {
}

bool hasAttribute(const std::string& attr) const {
#if R_VERSION >= R_Version(4, 6, 0)
return R_hasAttrib(static_cast<const CLASS&>(*this).get__(), Rf_install(attr.c_str()));
#else
return static_cast<const CLASS&>(*this).attr(attr) != R_NilValue;
#endif
}


Expand Down