Rcpp Version 0.12.12
routines.h
Go to the documentation of this file.
1 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 //
3 // Copyright (C) 2013 Romain Francois
4 // Copyright (C) 2015 Dirk Eddelbuettel
5 //
6 // This file is part of Rcpp.
7 //
8 // Rcpp is free software: you can redistribute it and/or modify it
9 // under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // Rcpp is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
20 
21 #ifndef RCPP_ROUTINE_H
22 #define RCPP_ROUTINE_H
23 
24 #if defined(COMPILING_RCPP)
25 
26 // the idea is that this file should be generated automatically by Rcpp::register
27 
28 namespace Rcpp{
29  const char* type2name(SEXP x);
30 
31  namespace internal{
32  unsigned long enterRNGScope();
33  unsigned long exitRNGScope();
34  char* get_string_buffer();
35  SEXP get_Rcpp_namespace();
36  }
37  double mktime00(struct tm &);
38  struct tm * gmtime_(const time_t * const);
39 }
40 
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 = -1);
47 SEXP get_string_elt(SEXP s, R_xlen_t i);
48 const char* char_get_string_elt(SEXP s, R_xlen_t i);
49 void set_string_elt(SEXP s, R_xlen_t i, SEXP v);
50 void char_set_string_elt(SEXP s, R_xlen_t i, const char* v);
51 SEXP* get_string_ptr(SEXP s);
52 SEXP get_vector_elt(SEXP v, R_xlen_t i);
53 void set_vector_elt(SEXP v, R_xlen_t i, SEXP x);
54 SEXP* get_vector_ptr(SEXP v);
55 const char* char_nocheck(SEXP x);
56 void* dataptr(SEXP x);
58 void setCurrentScope( Rcpp::Module* mod );
59 SEXP reset_current_error();
60 int error_occured();
62 // void print(SEXP s);
63 
64 #else
65 
66 namespace Rcpp {
67 
68  #define GET_CALLABLE(__FUN__) (Fun) R_GetCCallable( "Rcpp", __FUN__ )
69 
70  inline attribute_hidden const char* type2name(SEXP x){
71  typedef const char* (*Fun)(SEXP);
72  static Fun fun = GET_CALLABLE("type2name");
73  return fun(x);
74  }
75 
76  namespace internal{
77  inline attribute_hidden unsigned long enterRNGScope(){
78  typedef unsigned long (*Fun)(void);
79  static Fun fun = GET_CALLABLE("enterRNGScope");
80  return fun();
81  }
82 
83  inline attribute_hidden unsigned long exitRNGScope(){
84  typedef unsigned long (*Fun)(void);
85  static Fun fun = GET_CALLABLE("exitRNGScope");
86  return fun();
87  }
88 
89  inline attribute_hidden char* get_string_buffer(){
90  typedef char* (*Fun)(void);
91  static Fun fun = GET_CALLABLE("get_string_buffer");
92  return fun();
93  }
94 
95  inline attribute_hidden SEXP get_Rcpp_namespace() {
96  typedef SEXP (*Fun)(void);
97  static Fun fun = GET_CALLABLE("get_Rcpp_namespace");
98  return fun();
99  }
100 
101  }
102 
103 
104  inline attribute_hidden double mktime00(struct tm &tm){
105  typedef double (*Fun)(struct tm&);
106  static Fun fun = GET_CALLABLE("mktime00");
107  return fun(tm);
108  }
109 
110  inline attribute_hidden struct tm * gmtime_(const time_t * const x){
111  typedef struct tm* (*Fun)(const time_t* const);
112  static Fun fun = GET_CALLABLE("gmtime_");
113  return fun(x);
114  }
115 
116 }
117 
118 // The 'attribute_hidden' used here is a simple precessor defined from
119 // ${R_HOME}/include/R_ext/Visibility.h -- it is empty when not supported
120 // by the compiler and otherwise '__attribute__ ((visibility ("hidden")))'
121 
122 inline attribute_hidden SEXP rcpp_get_stack_trace(){
123  typedef SEXP (*Fun)(void);
124  static Fun fun = GET_CALLABLE("rcpp_get_stack_trace");
125  return fun();
126 }
127 
128 inline attribute_hidden SEXP rcpp_set_stack_trace(SEXP e){
129  typedef SEXP (*Fun)(SEXP);
130  static Fun fun = GET_CALLABLE("rcpp_set_stack_trace");
131  return fun(e);
132 }
133 
134 inline attribute_hidden std::string demangle( const std::string& name){
135  typedef std::string (*Fun)( const std::string& );
136  static Fun fun = GET_CALLABLE("demangle");
137  return fun(name);
138 }
139 
140 inline attribute_hidden const char* short_file_name(const char* file) {
141  typedef const char* (*Fun)(const char*);
142  static Fun fun = GET_CALLABLE("short_file_name");
143  return fun(file);
144 }
145 
146 inline attribute_hidden SEXP stack_trace( const char *file = "", int line = -1){
147  typedef SEXP (*Fun)(const char*, int);
148  static Fun fun = GET_CALLABLE("stack_trace");
149  return fun(file, line);
150 }
151 
152 inline attribute_hidden SEXP get_string_elt(SEXP s, R_xlen_t i){
153  typedef SEXP (*Fun)(SEXP, R_xlen_t);
154  static Fun fun = GET_CALLABLE("get_string_elt");
155  return fun(s, i);
156 }
157 
158 inline attribute_hidden const char* char_get_string_elt(SEXP s, R_xlen_t i){
159  typedef const char* (*Fun)(SEXP, R_xlen_t);
160  static Fun fun = GET_CALLABLE("char_get_string_elt");
161  return fun(s, i);
162 }
163 
164 inline attribute_hidden void set_string_elt(SEXP s, R_xlen_t i, SEXP v){
165  typedef void (*Fun)(SEXP, R_xlen_t, SEXP);
166  static Fun fun = GET_CALLABLE("set_string_elt");
167  fun(s, i, v);
168 }
169 
170 inline attribute_hidden void char_set_string_elt(SEXP s, R_xlen_t i, const char* v){
171  typedef void (*Fun)(SEXP, R_xlen_t, const char*);
172  static Fun fun = GET_CALLABLE("char_set_string_elt");
173  fun(s, i, v );
174 }
175 
176 inline attribute_hidden SEXP* get_string_ptr(SEXP s){
177  typedef SEXP* (*Fun)(SEXP);
178  static Fun fun = GET_CALLABLE("get_string_ptr");
179  return fun(s);
180 }
181 
182 inline attribute_hidden SEXP get_vector_elt(SEXP v, R_xlen_t i){
183  typedef SEXP (*Fun)(SEXP, R_xlen_t);
184  static Fun fun = GET_CALLABLE("get_vector_elt");
185  return fun(v, i);
186 }
187 
188 inline attribute_hidden void set_vector_elt(SEXP v, R_xlen_t i, SEXP x){
189  typedef void (*Fun)(SEXP, R_xlen_t, SEXP);
190  static Fun fun = GET_CALLABLE("set_vector_elt");
191  fun(v, i, x);
192 }
193 
194 inline attribute_hidden SEXP* get_vector_ptr(SEXP v){
195  typedef SEXP* (*Fun)(SEXP);
196  static Fun fun = GET_CALLABLE("get_vector_ptr");
197  return fun(v);
198 }
199 
200 inline attribute_hidden const char* char_nocheck( SEXP x){
201  typedef const char* (*Fun)(SEXP);
202  static Fun fun = GET_CALLABLE("char_nocheck");
203  return fun(x);
204 }
205 
206 inline attribute_hidden void* dataptr(SEXP x){
207  typedef void* (*Fun)(SEXP);
208  static Fun fun = GET_CALLABLE("dataptr");
209  return fun(x);
210 }
211 
212 inline attribute_hidden Rcpp::Module* getCurrentScope(){
213  typedef Rcpp::Module* (*Fun)(void);
214  static Fun fun = GET_CALLABLE("getCurrentScope");
215  return fun();
216 }
217 
218 inline attribute_hidden void setCurrentScope( Rcpp::Module* mod ){
219  typedef void (*Fun)(Rcpp::Module*);
220  static Fun fun = GET_CALLABLE("setCurrentScope");
221  fun(mod);
222 }
223 
224 inline attribute_hidden int* get_cache( int n ){
225  typedef int* (*Fun)(int);
226  static Fun fun = GET_CALLABLE("get_cache");
227  return fun(n);
228 }
229 
230 inline attribute_hidden SEXP reset_current_error(){
231  typedef SEXP (*Fun)(void);
232  static Fun fun = GET_CALLABLE("reset_current_error");
233  return fun();
234 }
235 
236 inline attribute_hidden int error_occured(){
237  typedef int (*Fun)(void);
238  static Fun fun = GET_CALLABLE("error_occured");
239  return fun();
240 }
241 
242 inline attribute_hidden SEXP rcpp_get_current_error(){
243  typedef SEXP (*Fun)(void);
244  static Fun fun = GET_CALLABLE("rcpp_get_current_error");
245  return fun();
246 }
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 
254 #endif
255 
256 
257 #endif
attribute_hidden void setCurrentScope(Rcpp::Module *mod)
Definition: routines.h:218
attribute_hidden SEXP * get_vector_ptr(SEXP v)
Definition: routines.h:194
attribute_hidden double mktime00(struct tm &tm)
Definition: routines.h:104
attribute_hidden SEXP stack_trace(const char *file="", int line=-1)
Definition: routines.h:146
attribute_hidden SEXP * get_string_ptr(SEXP s)
Definition: routines.h:176
attribute_hidden SEXP get_vector_elt(SEXP v, R_xlen_t i)
Definition: routines.h:182
attribute_hidden void set_string_elt(SEXP s, R_xlen_t i, SEXP v)
Definition: routines.h:164
attribute_hidden SEXP get_string_elt(SEXP s, R_xlen_t i)
Definition: routines.h:152
attribute_hidden std::string demangle(const std::string &name)
Definition: routines.h:134
attribute_hidden SEXP reset_current_error()
Definition: routines.h:230
attribute_hidden void set_vector_elt(SEXP v, R_xlen_t i, SEXP x)
Definition: routines.h:188
attribute_hidden void char_set_string_elt(SEXP s, R_xlen_t i, const char *v)
Definition: routines.h:170
attribute_hidden SEXP rcpp_get_current_error()
Definition: routines.h:242
#define GET_CALLABLE(__FUN__)
Definition: routines.h:68
attribute_hidden const char * char_nocheck(SEXP x)
Definition: routines.h:200
attribute_hidden unsigned long exitRNGScope()
Definition: routines.h:83
attribute_hidden SEXP rcpp_set_stack_trace(SEXP e)
Definition: routines.h:128
attribute_hidden const char * type2name(SEXP x)
Definition: routines.h:70
attribute_hidden void * dataptr(SEXP x)
Definition: routines.h:206
attribute_hidden int * get_cache(int n)
Definition: routines.h:224
attribute_hidden struct tm * gmtime_(const time_t *const x)
Definition: routines.h:110
attribute_hidden Rcpp::Module * getCurrentScope()
Definition: routines.h:212
attribute_hidden int error_occured()
Definition: routines.h:236
attribute_hidden unsigned long enterRNGScope()
Definition: routines.h:77
attribute_hidden char * get_string_buffer()
Definition: routines.h:89
attribute_hidden SEXP rcpp_get_stack_trace()
Definition: routines.h:122
attribute_hidden SEXP get_Rcpp_namespace()
Definition: routines.h:95
Rcpp API.
Definition: algo.h:28
static struct tm tm
Definition: Date.cpp:437
attribute_hidden const char * short_file_name(const char *file)
Definition: routines.h:140
attribute_hidden const char * char_get_string_elt(SEXP s, R_xlen_t i)
Definition: routines.h:158