A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/RcppCore/Rcpp/commit/9c5f71c0e6432966667708306352e3a112ad31dc below:

use read-only variants of {STRING/VECTOR}_PTR (#1317) · RcppCore/Rcpp@9c5f71c · GitHub

File tree Expand file treeCollapse file tree 7 files changed

+63

-9

lines changed

Filter options

Expand file treeCollapse file tree 7 files changed

+63

-9

lines changed Original file line number Diff line number Diff line change

@@ -1,3 +1,11 @@

1 +

2024-07-07 Kevin Ushey <kevinushey@gmail.com>

2 + 3 +

* inst/include/Rcpp/internal/SEXP_Iterator.h: Avoid using VECTOR_PTR

4 +

* inst/include/Rcpp/vector/Subsetter.h: Avoid using STRING_PTR

5 +

* inst/include/RcppCommon.h: Include compatibility defines

6 +

* src/barrier.cpp: Avoid using {STRING/VECTOR}_PTR

7 +

* inst/include/Rcpp/r/compat.h: Include compatibility defines

8 + 1 9

2024-06-22 Dirk Eddelbuettel <edd@debian.org>

2 10 3 11

* DESCRIPTION (Version, Date): Roll micro version

Original file line number Diff line number Diff line change

@@ -37,7 +37,7 @@ class SEXP_Iterator {

37 37 38 38

SEXP_Iterator( ): ptr(){} ;

39 39

SEXP_Iterator( const SEXP_Iterator& other) : ptr(other.ptr){} ;

40 -

SEXP_Iterator( const VECTOR& vec ) : ptr( get_vector_ptr(vec) ){} ;

40 +

SEXP_Iterator( const VECTOR& vec ) : ptr( RCPP_VECTOR_PTR(vec) ){} ;

41 41 42 42

SEXP_Iterator& operator=(const SEXP_Iterator& other){ ptr = other.ptr ; return *this ;}

43 43 Original file line number Diff line number Diff line change

@@ -0,0 +1,39 @@

1 + 2 +

//

3 +

// compat.h: Rcpp R/C++ interface class library -- compatibility defines

4 +

//

5 +

// Copyright (C) 2024 Dirk Eddelbuettel, Kevin Ushey

6 +

//

7 +

// This file is part of Rcpp.

8 +

//

9 +

// Rcpp is free software: you can redistribute it and/or modify it

10 +

// under the terms of the GNU General Public License as published by

11 +

// the Free Software Foundation, either version 2 of the License, or

12 +

// (at your option) any later version.

13 +

//

14 +

// Rcpp is distributed in the hope that it will be useful, but

15 +

// WITHOUT ANY WARRANTY; without even the implied warranty of

16 +

// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

17 +

// GNU General Public License for more details.

18 +

//

19 +

// You should have received a copy of the GNU General Public License

20 +

// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.

21 + 22 +

#ifndef RCPP_R_COMPAT_H

23 +

#define RCPP_R_COMPAT_H

24 + 25 +

#include <Rversion.h>

26 + 27 +

#if R_VERSION >= R_Version(4, 4, 2)

28 +

# define RCPP_STRING_PTR STRING_PTR_RO

29 +

#else

30 +

# define RCPP_STRING_PTR STRING_PTR

31 +

#endif

32 + 33 +

#if R_VERSION >= R_Version(4, 4, 2)

34 +

# define RCPP_VECTOR_PTR VECTOR_PTR_RO

35 +

#else

36 +

# define RCPP_VECTOR_PTR VECTOR_PTR

37 +

#endif

38 + 39 +

#endif /* RCPP_R_COMPAT_H */

Original file line number Diff line number Diff line change

@@ -174,10 +174,10 @@ class SubsetProxy {

174 174

indices.reserve(rhs_n);

175 175

SEXP names = Rf_getAttrib(lhs, R_NamesSymbol);

176 176

if (Rf_isNull(names)) stop("names is null");

177 -

SEXP* namesPtr = STRING_PTR(names);

178 -

SEXP* rhsPtr = STRING_PTR(rhs);

177 +

const SEXP* namesPtr = RCPP_STRING_PTR(names);

178 +

const SEXP* rhsPtr = RCPP_STRING_PTR(rhs);

179 179

for (R_xlen_t i = 0; i < rhs_n; ++i) {

180 -

SEXP* match = std::find(namesPtr, namesPtr + lhs_n, *(rhsPtr + i));

180 +

const SEXP* match = std::find(namesPtr, namesPtr + lhs_n, *(rhsPtr + i));

181 181

if (match == namesPtr + lhs_n)

182 182

stop("not found");

183 183

indices.push_back(match - namesPtr);

Original file line number Diff line number Diff line change

@@ -28,6 +28,7 @@

28 28

// #define RCPP_DEBUG_MODULE_LEVEL 1

29 29 30 30

#include <Rcpp/r/headers.h>

31 +

#include <Rcpp/r/compat.h>

31 32 32 33

/**

33 34

* \brief Rcpp API

Original file line number Diff line number Diff line change

@@ -112,7 +112,7 @@ namespace Rcpp {

112 112

case BCODESXP: return "BCODESXP";

113 113

case EXTPTRSXP: return "EXTPTRSXP";

114 114

case WEAKREFSXP: return "WEAKREFSXP";

115 -

#if R_Version >= R_Version(4,4,0) // replaces S4SXP in R 4.4.0

115 +

#if R_VERSION >= R_Version(4,4,0) // replaces S4SXP in R 4.4.0

116 116

case OBJSXP: return Rf_isS4(x) ? "S4SXP" : "OBJSXP"; // cf src/main/inspect.c

117 117

#else

118 118

case S4SXP: return "S4SXP";

Original file line number Diff line number Diff line change

@@ -22,11 +22,15 @@

22 22

#define COMPILING_RCPP

23 23 24 24

#define USE_RINTERNALS

25 + 26 +

#include <algorithm>

25 27

#include <Rinternals.h>

28 + 26 29

#include <Rcpp/barrier.h>

27 -

#include "internal.h"

28 -

#include <algorithm>

29 30

#include <Rcpp/protection/Shield.h>

31 +

#include <Rcpp/r/compat.h>

32 + 33 +

#include "internal.h"

30 34 31 35

// [[Rcpp::register]]

32 36

SEXP get_string_elt(SEXP x, R_xlen_t i) { // #nocov start

@@ -50,7 +54,8 @@ void char_set_string_elt(SEXP x, R_xlen_t i, const char* value) {

50 54 51 55

// [[Rcpp::register]]

52 56

SEXP* get_string_ptr(SEXP x) {

53 -

return STRING_PTR(x);

57 +

// TODO: should we deprecate this?

58 +

return const_cast<SEXP*>(RCPP_STRING_PTR(x));

54 59

}

55 60 56 61

// [[Rcpp::register]]

@@ -65,7 +70,8 @@ void set_vector_elt(SEXP x, R_xlen_t i, SEXP value) {

65 70 66 71

// [[Rcpp::register]]

67 72

SEXP* get_vector_ptr(SEXP x) {

68 -

return VECTOR_PTR(x); // #nocov end

73 +

// TODO: should we deprecate this?

74 +

return const_cast<SEXP*>(RCPP_VECTOR_PTR(x)); // #nocov end

69 75

}

70 76 71 77

// [[Rcpp::register]]

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4