Skip to content

Commit 3f92f23

Browse files
committed
Merge pull request #269 from RcppCore/feature/print-function
Feature/print function
2 parents 03a96ba + 75db27d commit 3f92f23

File tree

7 files changed

+55
-29
lines changed

7 files changed

+55
-29
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2015-03-01 Dirk Eddelbuettel <[email protected]>
2+
3+
* src/api.cpp: New function print() as a wrapper around Rf_PrintValue()
4+
* src/Rcpp_init.cpp: Corresponding registration for print()
5+
* inst/include/Rcpp/routines.h: Corresponding initialization
6+
17
2015-02-25 Dirk Eddelbuettel <[email protected]>
28

39
* inst/include/Rcpp/routines.h: Use the 'attribute_hidden' define from

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: Rcpp
22
Title: Seamless R and C++ Integration
3-
Version: 0.11.4.8
4-
Date: 2015-02-25
3+
Version: 0.11.4.9
4+
Date: 2015-03-01
55
Author: Dirk Eddelbuettel, Romain Francois, JJ Allaire, Kevin Ushey,
66
Douglas Bates, and John Chambers
77
Maintainer: Dirk Eddelbuettel <[email protected]>

inst/NEWS.Rd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
exception rather than crash) when a NULL external pointer is dereferenced.
1515
\item R code is evaluated within an \code{R_toplevelExec} block to prevent
1616
user interrupts from bypassing C++ destructors on the stack.
17+
\item A new function \code{print} function was added as a wrapper around
18+
\code{Rf_PrintValue}.
1719
}
1820
\item Changes in Rcpp Attributes:
1921
\itemize{

inst/include/Rcpp/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#define RCPP_VERSION Rcpp_Version(0,11,4)
3131

3232
// the current source snapshot
33-
#define RCPP_DEV_VERSION RcppDevVersion(0,11,4,8)
33+
#define RCPP_DEV_VERSION RcppDevVersion(0,11,4,9)
3434

3535
#endif
3636

inst/include/Rcpp/routines.h

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,31 @@ namespace Rcpp{
3838
struct tm * gmtime_(const time_t * const);
3939
}
4040

41-
SEXP rcpp_get_stack_trace();
42-
SEXP rcpp_set_stack_trace(SEXP);
43-
std::string demangle( const std::string& name);
44-
const char* short_file_name(const char* );
45-
int* get_cache( int n );
46-
SEXP stack_trace( const char *file, int line);
47-
SEXP get_string_elt(SEXP s, int i);
48-
const char* char_get_string_elt(SEXP s, int i);
49-
void set_string_elt(SEXP s, int i, SEXP v);
50-
void char_set_string_elt(SEXP s, int i, const char* v);
51-
SEXP* get_string_ptr(SEXP s);
52-
SEXP get_vector_elt(SEXP v, int i);
53-
void set_vector_elt(SEXP v, int i, SEXP x);
54-
SEXP* get_vector_ptr(SEXP v);
55-
const char* char_nocheck( SEXP x);
56-
void* dataptr(SEXP x);
41+
SEXP rcpp_get_stack_trace();
42+
SEXP rcpp_set_stack_trace(SEXP);
43+
std::string demangle(const std::string& name);
44+
const char* short_file_name(const char* );
45+
int* get_cache(int n);
46+
SEXP stack_trace( const char *file, int line);
47+
SEXP get_string_elt(SEXP s, int i);
48+
const char* char_get_string_elt(SEXP s, int i);
49+
void set_string_elt(SEXP s, int i, SEXP v);
50+
void char_set_string_elt(SEXP s, int i, const char* v);
51+
SEXP* get_string_ptr(SEXP s);
52+
SEXP get_vector_elt(SEXP v, int i);
53+
void set_vector_elt(SEXP v, int i, SEXP x);
54+
SEXP* get_vector_ptr(SEXP v);
55+
const char* char_nocheck(SEXP x);
56+
void* dataptr(SEXP x);
5757
Rcpp::Module* getCurrentScope();
58-
void setCurrentScope( Rcpp::Module* mod );
59-
SEXP reset_current_error();
60-
int error_occured();
61-
SEXP rcpp_get_current_error();
58+
void setCurrentScope( Rcpp::Module* mod );
59+
SEXP reset_current_error();
60+
int error_occured();
61+
SEXP rcpp_get_current_error();
62+
void print(SEXP s);
6263

6364
#else
65+
6466
namespace Rcpp {
6567

6668
#define GET_CALLABLE(__FUN__) (Fun) R_GetCCallable( "Rcpp", __FUN__ )
@@ -140,6 +142,7 @@ inline attribute_hidden const char* short_file_name(const char* file) {
140142
static Fun fun = GET_CALLABLE("short_file_name");
141143
return fun(file);
142144
}
145+
143146
inline attribute_hidden SEXP stack_trace( const char *file, int line){
144147
typedef SEXP (*Fun)(const char*, int);
145148
static Fun fun = GET_CALLABLE("stack_trace");
@@ -235,11 +238,19 @@ inline attribute_hidden int error_occured(){
235238
static Fun fun = GET_CALLABLE("error_occured");
236239
return fun();
237240
}
241+
238242
inline attribute_hidden SEXP rcpp_get_current_error(){
239243
typedef SEXP (*Fun)(void);
240244
static Fun fun = GET_CALLABLE("rcpp_get_current_error");
241245
return fun();
242246
}
247+
248+
inline attribute_hidden void print(SEXP s) {
249+
typedef void (*Fun)(SEXP);
250+
static Fun fun = GET_CALLABLE("print");
251+
fun(s);
252+
}
253+
243254
#endif
244255

245256

src/Rcpp_init.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
1+
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
22
//
33
// Rcpp_init.cpp : Rcpp R/C++ interface class library -- Initialize and register
44
//
5-
// Copyright (C) 2010 - 2013 John Chambers, Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2010 - 2015 John Chambers, Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -116,6 +116,7 @@ void registerFunctions(){
116116
RCPP_REGISTER(reset_current_error)
117117
RCPP_REGISTER(error_occured)
118118
RCPP_REGISTER(rcpp_get_current_error)
119+
RCPP_REGISTER(print)
119120
#undef RCPP_REGISTER
120121
}
121122

src/api.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//
44
// api.cpp: Rcpp R/C++ interface class library -- Rcpp api
55
//
6-
// Copyright (C) 2012 - 2014 Dirk Eddelbuettel and Romain Francois
6+
// Copyright (C) 2012 - 2015 Dirk Eddelbuettel and Romain Francois
77
//
88
// This file is part of Rcpp.
99
//
@@ -56,7 +56,7 @@ using namespace Rcpp ;
5656

5757
namespace Rcpp {
5858

59-
namespace internal{
59+
namespace internal {
6060
namespace {
6161
unsigned long RNGScopeCounter = 0;
6262
}
@@ -294,8 +294,14 @@ SEXP stack_trace( const char* file, int line ){
294294
return trace ;
295295
#endif
296296
#else /* !defined( __GNUC__ ) */
297-
return R_NilValue ;
298-
#endif
297+
return R_NilValue ;
298+
#endif
299299
}
300+
301+
// [[Rcpp::register]]
302+
void print(SEXP s) {
303+
Rf_PrintValue(s); // defined in Rinternals.h
304+
}
305+
300306
// }}}
301307

0 commit comments

Comments
 (0)