File: routines.h

package info (click to toggle)
rcpp 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,480 kB
  • sloc: cpp: 27,436; ansic: 7,778; sh: 53; makefile: 2
file content (315 lines) | stat: -rw-r--r-- 10,029 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315

// routines.h: Rcpp R/C++ interface class library -- callable function setup
//
// Copyright (C) 2013 - 2014 Romain Francois
// Copyright (C) 2015 - 2020 Romain Francois and Dirk Eddelbuettel
// Copyright (C) 2021        Romain Francois, Dirk Eddelbuettel and IƱaki Ucar
//
// This file is part of Rcpp.
//
// Rcpp is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// Rcpp is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.

#ifndef RCPP_ROUTINE_H
#define RCPP_ROUTINE_H

#include <Rcpp/iostream/Rstreambuf.h>

#if defined(COMPILING_RCPP)

// the idea is that this file should be generated automatically by Rcpp::register

namespace Rcpp{
    const char* type2name(SEXP x);

    namespace internal{
        unsigned long enterRNGScope();
        unsigned long exitRNGScope();
        unsigned long beginSuspendRNGSynchronization();
        unsigned long endSuspendRNGSynchronization();
        char* get_string_buffer();
        SEXP get_Rcpp_namespace();
    }
    double mktime00(struct tm &);
    struct tm * gmtime_(const time_t * const);

    void Rcpp_precious_init();
    void Rcpp_precious_teardown();
    SEXP Rcpp_precious_preserve(SEXP object);
    void Rcpp_precious_remove(SEXP token);

    Rostream<true>&  Rcpp_cout_get();
    Rostream<false>& Rcpp_cerr_get();
}

SEXP          rcpp_get_stack_trace();
SEXP          rcpp_set_stack_trace(SEXP);
std::string   demangle(const std::string& name);
const char*   short_file_name(const char* );
int*          get_cache(int n);
SEXP          stack_trace( const char *file = "", int line = -1);
SEXP          get_string_elt(SEXP s, R_xlen_t i);
const char*   char_get_string_elt(SEXP s, R_xlen_t i);
void          set_string_elt(SEXP s, R_xlen_t i, SEXP v);
void          char_set_string_elt(SEXP s, R_xlen_t i, const char* v);
SEXP*         get_string_ptr(SEXP s);
SEXP          get_vector_elt(SEXP v, R_xlen_t i);
void          set_vector_elt(SEXP v, R_xlen_t i, SEXP x);
SEXP*         get_vector_ptr(SEXP v);
const char*   char_nocheck(SEXP x);
void*         dataptr(SEXP x);
Rcpp::Module* getCurrentScope();
void          setCurrentScope( Rcpp::Module* mod );
SEXP          reset_current_error();
int           error_occured();
SEXP          rcpp_get_current_error();
// void          print(SEXP s);

#else

namespace Rcpp {

    #define GET_CALLABLE(__FUN__) (Fun) R_GetCCallable( "Rcpp", __FUN__ )

    inline attribute_hidden const char* type2name(SEXP x){
        typedef const char* (*Fun)(SEXP);
        static Fun fun = GET_CALLABLE("type2name");
        return fun(x);
    }

    namespace internal{
        inline attribute_hidden unsigned long enterRNGScope(){
            typedef unsigned long (*Fun)(void);
            static Fun fun = GET_CALLABLE("enterRNGScope");
            return fun();
        }

        inline attribute_hidden unsigned long exitRNGScope(){
            typedef unsigned long (*Fun)(void);
            static Fun fun = GET_CALLABLE("exitRNGScope");
            return fun();
        }

        inline attribute_hidden unsigned long beginSuspendRNGSynchronization(){
            typedef unsigned long (*Fun)(void);
            static Fun fun = GET_CALLABLE("beginSuspendRNGSynchronization");
            return fun();
        }

        inline attribute_hidden unsigned long endSuspendRNGSynchronization(){
            typedef unsigned long (*Fun)(void);
            static Fun fun = GET_CALLABLE("endSuspendRNGSynchronization");
            return fun();
        }

        inline attribute_hidden char* get_string_buffer(){
            typedef char* (*Fun)(void);
            static Fun fun = GET_CALLABLE("get_string_buffer");
            return fun();
        }

        inline attribute_hidden SEXP get_Rcpp_namespace() {
            typedef SEXP (*Fun)(void);
            static Fun fun = GET_CALLABLE("get_Rcpp_namespace");
            return fun();
        }

    }


    inline attribute_hidden double mktime00(struct tm &tm){
        typedef double (*Fun)(struct tm&);
        static Fun fun = GET_CALLABLE("mktime00");
        return fun(tm);
    }

    inline attribute_hidden struct tm * gmtime_(const time_t * const x){
        typedef struct tm* (*Fun)(const time_t* const);
        static Fun fun =  GET_CALLABLE("gmtime_");
        return fun(x);
    }

    inline attribute_hidden void Rcpp_precious_init() {
        typedef void (*Fun)(void);
        static Fun fun = GET_CALLABLE("Rcpp_precious_init");
        fun();
    }
    inline attribute_hidden void Rcpp_precious_teardown() {
        typedef void (*Fun)(void);
        static Fun fun = GET_CALLABLE("Rcpp_precious_teardown");
        fun();
    }
    inline attribute_hidden SEXP Rcpp_precious_preserve(SEXP object) {
        typedef SEXP (*Fun)(SEXP);
        static Fun fun = GET_CALLABLE("Rcpp_precious_preserve");
        return fun(object);
    }
    inline attribute_hidden void Rcpp_precious_remove(SEXP token) {
        typedef void (*Fun)(SEXP);
        static Fun fun = GET_CALLABLE("Rcpp_precious_remove");
        fun(token);
    }

    inline attribute_hidden Rostream<true>&  Rcpp_cout_get() {
        typedef Rostream<true>& (*Fun)();
        static Fun fun = GET_CALLABLE("Rcpp_cout_get");
        return fun();
    }
    inline attribute_hidden Rostream<false>& Rcpp_cerr_get() {
        typedef Rostream<false>& (*Fun)();
        static Fun fun = GET_CALLABLE("Rcpp_cerr_get");
        return fun();
    }

}

// The 'attribute_hidden' used here is a simple precessor defined from
// ${R_HOME}/include/R_ext/Visibility.h -- it is empty when not supported
// by the compiler and otherwise '__attribute__ ((visibility ("hidden")))'

inline attribute_hidden SEXP rcpp_get_stack_trace(){
    typedef SEXP (*Fun)(void);
    static Fun fun = GET_CALLABLE("rcpp_get_stack_trace");
    return fun();
}

inline attribute_hidden SEXP rcpp_set_stack_trace(SEXP e){
    typedef SEXP (*Fun)(SEXP);
    static Fun fun =  GET_CALLABLE("rcpp_set_stack_trace");
    return fun(e);
}

inline attribute_hidden std::string demangle( const std::string& name){
    typedef std::string (*Fun)( const std::string& );
    static Fun fun = GET_CALLABLE("demangle");
    return fun(name);
}

inline attribute_hidden const char* short_file_name(const char* file) {
    typedef const char* (*Fun)(const char*);
    static Fun fun = GET_CALLABLE("short_file_name");
    return fun(file);
}

inline attribute_hidden SEXP stack_trace( const char *file = "", int line = -1){
    typedef SEXP (*Fun)(const char*, int);
    static Fun fun = GET_CALLABLE("stack_trace");
    return fun(file, line);
}

inline attribute_hidden SEXP get_string_elt(SEXP s, R_xlen_t i){
    typedef SEXP (*Fun)(SEXP, R_xlen_t);
    static Fun fun = GET_CALLABLE("get_string_elt");
    return fun(s, i);
}

inline attribute_hidden const char* char_get_string_elt(SEXP s, R_xlen_t i){
    typedef const char* (*Fun)(SEXP, R_xlen_t);
    static Fun fun = GET_CALLABLE("char_get_string_elt");
    return fun(s, i);
}

inline attribute_hidden void set_string_elt(SEXP s, R_xlen_t i, SEXP v){
    typedef void (*Fun)(SEXP, R_xlen_t, SEXP);
    static Fun fun = GET_CALLABLE("set_string_elt");
    fun(s, i, v);
}

inline attribute_hidden void char_set_string_elt(SEXP s, R_xlen_t i, const char* v){
    typedef void (*Fun)(SEXP, R_xlen_t, const char*);
    static Fun fun = GET_CALLABLE("char_set_string_elt");
    fun(s, i, v );
}

inline attribute_hidden SEXP* get_string_ptr(SEXP s){
    typedef SEXP* (*Fun)(SEXP);
    static Fun fun = GET_CALLABLE("get_string_ptr");
    return fun(s);
}

inline attribute_hidden SEXP get_vector_elt(SEXP v, R_xlen_t i){
    typedef SEXP (*Fun)(SEXP, R_xlen_t);
    static Fun fun = GET_CALLABLE("get_vector_elt");
    return fun(v, i);
}

inline attribute_hidden void set_vector_elt(SEXP v, R_xlen_t i, SEXP x){
    typedef void (*Fun)(SEXP, R_xlen_t, SEXP);
    static Fun fun = GET_CALLABLE("set_vector_elt");
    fun(v, i, x);
}

inline attribute_hidden SEXP* get_vector_ptr(SEXP v){
    typedef SEXP* (*Fun)(SEXP);
    static Fun fun = GET_CALLABLE("get_vector_ptr");
    return fun(v);
}

inline attribute_hidden const char* char_nocheck( SEXP x){
    typedef const char* (*Fun)(SEXP);
    static Fun fun = GET_CALLABLE("char_nocheck");
    return fun(x);
}

inline attribute_hidden void* dataptr(SEXP x){
    typedef void* (*Fun)(SEXP);
    static Fun fun = GET_CALLABLE("dataptr");
    return fun(x);
}

inline attribute_hidden Rcpp::Module* getCurrentScope(){
    typedef Rcpp::Module* (*Fun)(void);
    static Fun fun = GET_CALLABLE("getCurrentScope");
    return fun();
}

inline attribute_hidden void setCurrentScope( Rcpp::Module* mod ){
    typedef void (*Fun)(Rcpp::Module*);
    static Fun fun = GET_CALLABLE("setCurrentScope");
    fun(mod);
}

inline attribute_hidden int* get_cache( int n ){
    typedef int* (*Fun)(int);
    static Fun fun = GET_CALLABLE("get_cache");
    return fun(n);
}

inline attribute_hidden SEXP reset_current_error(){
    typedef SEXP (*Fun)(void);
    static Fun fun = GET_CALLABLE("reset_current_error");
    return fun();
}

inline attribute_hidden int error_occured(){
    typedef int (*Fun)(void);
    static Fun fun = GET_CALLABLE("error_occured");
    return fun();
}

inline attribute_hidden SEXP rcpp_get_current_error(){
    typedef SEXP (*Fun)(void);
    static Fun fun = GET_CALLABLE("rcpp_get_current_error");
    return fun();
}

// inline attribute_hidden void print(SEXP s) {
//     typedef void (*Fun)(SEXP);
//     static Fun fun = GET_CALLABLE("print");
//     fun(s);
// }

#endif


#endif