Rcpp Version 1.0.14
Loading...
Searching...
No Matches
routines.h
Go to the documentation of this file.
1
2// routines.h: Rcpp R/C++ interface class library -- callable function setup
3//
4// Copyright (C) 2013 - 2014 Romain Francois
5// Copyright (C) 2015 - 2020 Romain Francois and Dirk Eddelbuettel
6// Copyright (C) 2021 Romain Francois, Dirk Eddelbuettel and IƱaki Ucar
7//
8// This file is part of Rcpp.
9//
10// Rcpp is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 2 of the License, or
13// (at your option) any later version.
14//
15// Rcpp is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
22
23#ifndef RCPP_ROUTINE_H
24#define RCPP_ROUTINE_H
25
27
28#if defined(COMPILING_RCPP)
29
30// the idea is that this file should be generated automatically by Rcpp::register
31
32namespace Rcpp{
33 const char* type2name(SEXP x);
34
35 namespace internal{
36 unsigned long enterRNGScope();
37 unsigned long exitRNGScope();
38 unsigned long beginSuspendRNGSynchronization();
39 unsigned long endSuspendRNGSynchronization();
40 char* get_string_buffer();
42 }
43 double mktime00(struct tm &);
44 struct tm * gmtime_(const time_t * const);
45
46 void Rcpp_precious_init();
49 void Rcpp_precious_remove(SEXP token);
50
53}
54
56SEXP rcpp_set_stack_trace(SEXP);
57std::string demangle(const std::string& name);
58const char* short_file_name(const char* );
59int* get_cache(int n);
60SEXP stack_trace( const char *file = "", int line = -1);
61SEXP get_string_elt(SEXP s, R_xlen_t i);
62const char* char_get_string_elt(SEXP s, R_xlen_t i);
63void set_string_elt(SEXP s, R_xlen_t i, SEXP v);
64void char_set_string_elt(SEXP s, R_xlen_t i, const char* v);
65SEXP* get_string_ptr(SEXP s);
66SEXP get_vector_elt(SEXP v, R_xlen_t i);
67void set_vector_elt(SEXP v, R_xlen_t i, SEXP x);
68SEXP* get_vector_ptr(SEXP v);
69const char* char_nocheck(SEXP x);
70void* dataptr(SEXP x);
72void setCurrentScope( Rcpp::Module* mod );
74int error_occured();
76// void print(SEXP s);
77
78#else
79
80namespace Rcpp {
81
82 #define GET_CALLABLE(__FUN__) (Fun) R_GetCCallable( "Rcpp", __FUN__ )
83
84 inline attribute_hidden const char* type2name(SEXP x){
85 typedef const char* (*Fun)(SEXP);
86 static Fun fun = GET_CALLABLE("type2name");
87 return fun(x);
88 }
89
90 namespace internal{
91 inline attribute_hidden unsigned long enterRNGScope(){
92 typedef unsigned long (*Fun)(void);
93 static Fun fun = GET_CALLABLE("enterRNGScope");
94 return fun();
95 }
96
97 inline attribute_hidden unsigned long exitRNGScope(){
98 typedef unsigned long (*Fun)(void);
99 static Fun fun = GET_CALLABLE("exitRNGScope");
100 return fun();
101 }
102
104 typedef unsigned long (*Fun)(void);
105 static Fun fun = GET_CALLABLE("beginSuspendRNGSynchronization");
106 return fun();
107 }
108
110 typedef unsigned long (*Fun)(void);
111 static Fun fun = GET_CALLABLE("endSuspendRNGSynchronization");
112 return fun();
113 }
114
116 typedef char* (*Fun)(void);
117 static Fun fun = GET_CALLABLE("get_string_buffer");
118 return fun();
119 }
120
122 typedef SEXP (*Fun)(void);
123 static Fun fun = GET_CALLABLE("get_Rcpp_namespace");
124 return fun();
125 }
126
127 }
128
129
130 inline attribute_hidden double mktime00(struct tm &tm){
131 typedef double (*Fun)(struct tm&);
132 static Fun fun = GET_CALLABLE("mktime00");
133 return fun(tm);
134 }
135
136 inline attribute_hidden struct tm * gmtime_(const time_t * const x){
137 typedef struct tm* (*Fun)(const time_t* const);
138 static Fun fun = GET_CALLABLE("gmtime_");
139 return fun(x);
140 }
141
143 typedef void (*Fun)(void);
144 static Fun fun = GET_CALLABLE("Rcpp_precious_init");
145 fun();
146 }
148 typedef void (*Fun)(void);
149 static Fun fun = GET_CALLABLE("Rcpp_precious_teardown");
150 fun();
151 }
153 typedef SEXP (*Fun)(SEXP);
154 static Fun fun = GET_CALLABLE("Rcpp_precious_preserve");
155 return fun(object);
156 }
158 typedef void (*Fun)(SEXP);
159 static Fun fun = GET_CALLABLE("Rcpp_precious_remove");
160 fun(token);
161 }
162
164 typedef Rostream<true>& (*Fun)();
165 static Fun fun = GET_CALLABLE("Rcpp_cout_get");
166 return fun();
167 }
169 typedef Rostream<false>& (*Fun)();
170 static Fun fun = GET_CALLABLE("Rcpp_cerr_get");
171 return fun();
172 }
173
174}
175
176// The 'attribute_hidden' used here is a simple precessor defined from
177// ${R_HOME}/include/R_ext/Visibility.h -- it is empty when not supported
178// by the compiler and otherwise '__attribute__ ((visibility ("hidden")))'
179
180inline attribute_hidden SEXP rcpp_get_stack_trace(){
181 typedef SEXP (*Fun)(void);
182 static Fun fun = GET_CALLABLE("rcpp_get_stack_trace");
183 return fun();
184}
185
186inline attribute_hidden SEXP rcpp_set_stack_trace(SEXP e){
187 typedef SEXP (*Fun)(SEXP);
188 static Fun fun = GET_CALLABLE("rcpp_set_stack_trace");
189 return fun(e);
190}
191
192inline attribute_hidden std::string demangle( const std::string& name){
193 typedef std::string (*Fun)( const std::string& );
194 static Fun fun = GET_CALLABLE("demangle");
195 return fun(name);
196}
197
198inline attribute_hidden const char* short_file_name(const char* file) {
199 typedef const char* (*Fun)(const char*);
200 static Fun fun = GET_CALLABLE("short_file_name");
201 return fun(file);
202}
203
204inline attribute_hidden SEXP stack_trace( const char *file = "", int line = -1){
205 typedef SEXP (*Fun)(const char*, int);
206 static Fun fun = GET_CALLABLE("stack_trace");
207 return fun(file, line);
208}
209
210inline attribute_hidden SEXP get_string_elt(SEXP s, R_xlen_t i){
211 typedef SEXP (*Fun)(SEXP, R_xlen_t);
212 static Fun fun = GET_CALLABLE("get_string_elt");
213 return fun(s, i);
214}
215
216inline attribute_hidden const char* char_get_string_elt(SEXP s, R_xlen_t i){
217 typedef const char* (*Fun)(SEXP, R_xlen_t);
218 static Fun fun = GET_CALLABLE("char_get_string_elt");
219 return fun(s, i);
220}
221
222inline attribute_hidden void set_string_elt(SEXP s, R_xlen_t i, SEXP v){
223 typedef void (*Fun)(SEXP, R_xlen_t, SEXP);
224 static Fun fun = GET_CALLABLE("set_string_elt");
225 fun(s, i, v);
226}
227
228inline attribute_hidden void char_set_string_elt(SEXP s, R_xlen_t i, const char* v){
229 typedef void (*Fun)(SEXP, R_xlen_t, const char*);
230 static Fun fun = GET_CALLABLE("char_set_string_elt");
231 fun(s, i, v );
232}
233
234inline attribute_hidden SEXP* get_string_ptr(SEXP s){
235 typedef SEXP* (*Fun)(SEXP);
236 static Fun fun = GET_CALLABLE("get_string_ptr");
237 return fun(s);
238}
239
240inline attribute_hidden SEXP get_vector_elt(SEXP v, R_xlen_t i){
241 typedef SEXP (*Fun)(SEXP, R_xlen_t);
242 static Fun fun = GET_CALLABLE("get_vector_elt");
243 return fun(v, i);
244}
245
246inline attribute_hidden void set_vector_elt(SEXP v, R_xlen_t i, SEXP x){
247 typedef void (*Fun)(SEXP, R_xlen_t, SEXP);
248 static Fun fun = GET_CALLABLE("set_vector_elt");
249 fun(v, i, x);
250}
251
252inline attribute_hidden SEXP* get_vector_ptr(SEXP v){
253 typedef SEXP* (*Fun)(SEXP);
254 static Fun fun = GET_CALLABLE("get_vector_ptr");
255 return fun(v);
256}
257
258inline attribute_hidden const char* char_nocheck( SEXP x){
259 typedef const char* (*Fun)(SEXP);
260 static Fun fun = GET_CALLABLE("char_nocheck");
261 return fun(x);
262}
263
264inline attribute_hidden void* dataptr(SEXP x){
265 typedef void* (*Fun)(SEXP);
266 static Fun fun = GET_CALLABLE("dataptr");
267 return fun(x);
268}
269
270inline attribute_hidden Rcpp::Module* getCurrentScope(){
271 typedef Rcpp::Module* (*Fun)(void);
272 static Fun fun = GET_CALLABLE("getCurrentScope");
273 return fun();
274}
275
276inline attribute_hidden void setCurrentScope( Rcpp::Module* mod ){
277 typedef void (*Fun)(Rcpp::Module*);
278 static Fun fun = GET_CALLABLE("setCurrentScope");
279 fun(mod);
280}
281
282inline attribute_hidden int* get_cache( int n ){
283 typedef int* (*Fun)(int);
284 static Fun fun = GET_CALLABLE("get_cache");
285 return fun(n);
286}
287
288inline attribute_hidden SEXP reset_current_error(){
289 typedef SEXP (*Fun)(void);
290 static Fun fun = GET_CALLABLE("reset_current_error");
291 return fun();
292}
293
294inline attribute_hidden int error_occured(){
295 typedef int (*Fun)(void);
296 static Fun fun = GET_CALLABLE("error_occured");
297 return fun();
298}
299
300inline attribute_hidden SEXP rcpp_get_current_error(){
301 typedef SEXP (*Fun)(void);
302 static Fun fun = GET_CALLABLE("rcpp_get_current_error");
303 return fun();
304}
305
306// inline attribute_hidden void print(SEXP s) {
307// typedef void (*Fun)(SEXP);
308// static Fun fun = GET_CALLABLE("print");
309// fun(s);
310// }
311
312#endif
313
314
315#endif
attribute_hidden unsigned long exitRNGScope()
Definition routines.h:97
T as(SEXP x, ::Rcpp::traits::r_type_primitive_tag)
Definition as.h:43
attribute_hidden unsigned long beginSuspendRNGSynchronization()
Definition routines.h:103
attribute_hidden unsigned long enterRNGScope()
Definition routines.h:91
attribute_hidden char * get_string_buffer()
Definition routines.h:115
attribute_hidden unsigned long endSuspendRNGSynchronization()
Definition routines.h:109
attribute_hidden SEXP get_Rcpp_namespace()
Definition routines.h:121
Rcpp API.
Definition algo.h:28
attribute_hidden Rostream< true > & Rcpp_cout_get()
Definition routines.h:163
attribute_hidden void Rcpp_precious_init()
Definition routines.h:142
static struct tm tm
Definition date.cpp:435
attribute_hidden struct tm * gmtime_(const time_t *const x)
Definition routines.h:136
attribute_hidden SEXP Rcpp_precious_preserve(SEXP object)
Definition routines.h:152
attribute_hidden const char * type2name(SEXP x)
Definition routines.h:84
attribute_hidden Rostream< false > & Rcpp_cerr_get()
Definition routines.h:168
attribute_hidden double mktime00(struct tm &tm)
Definition routines.h:130
T as(SEXP x)
Definition as.h:151
attribute_hidden void Rcpp_precious_remove(SEXP token)
Definition routines.h:157
attribute_hidden void Rcpp_precious_teardown()
Definition routines.h:147
attribute_hidden SEXP rcpp_set_stack_trace(SEXP e)
Definition routines.h:186
attribute_hidden const char * char_nocheck(SEXP x)
Definition routines.h:258
attribute_hidden const char * short_file_name(const char *file)
Definition routines.h:198
attribute_hidden void char_set_string_elt(SEXP s, R_xlen_t i, const char *v)
Definition routines.h:228
attribute_hidden SEXP rcpp_get_current_error()
Definition routines.h:300
attribute_hidden SEXP * get_string_ptr(SEXP s)
Definition routines.h:234
attribute_hidden Rcpp::Module * getCurrentScope()
Definition routines.h:270
attribute_hidden const char * char_get_string_elt(SEXP s, R_xlen_t i)
Definition routines.h:216
attribute_hidden SEXP stack_trace(const char *file="", int line=-1)
Definition routines.h:204
attribute_hidden SEXP get_string_elt(SEXP s, R_xlen_t i)
Definition routines.h:210
attribute_hidden SEXP get_vector_elt(SEXP v, R_xlen_t i)
Definition routines.h:240
attribute_hidden int error_occured()
Definition routines.h:294
#define GET_CALLABLE(__FUN__)
Definition routines.h:82
attribute_hidden std::string demangle(const std::string &name)
Definition routines.h:192
attribute_hidden void set_string_elt(SEXP s, R_xlen_t i, SEXP v)
Definition routines.h:222
attribute_hidden SEXP rcpp_get_stack_trace()
Definition routines.h:180
attribute_hidden SEXP reset_current_error()
Definition routines.h:288
attribute_hidden void setCurrentScope(Rcpp::Module *mod)
Definition routines.h:276
attribute_hidden SEXP * get_vector_ptr(SEXP v)
Definition routines.h:252
attribute_hidden int * get_cache(int n)
Definition routines.h:282
attribute_hidden void * dataptr(SEXP x)
Definition routines.h:264
attribute_hidden void set_vector_elt(SEXP v, R_xlen_t i, SEXP x)
Definition routines.h:246