Rcpp Version 1.0.9
rcpp_init.cpp
Go to the documentation of this file.
1 
2 // Rcpp_init.cpp : Rcpp R/C++ interface class library -- Initialize and register
3 //
4 // Copyright (C) 2010 - 2020 John Chambers, Dirk Eddelbuettel and Romain Francois
5 // Copyright (C) 2021 John Chambers, Dirk Eddelbuettel, Romain Francois and IƱaki Ucar
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 #define COMPILING_RCPP
23 
24 #include <Rcpp.h>
25 #include "internal.h"
26 
27 // borrowed from Matrix
28 #define CALLDEF(name, n) {#name, (DL_FUNC) &name, n}
29 #define EXTDEF(name) {#name, (DL_FUNC) &name, -1}
30 
31 static R_CallMethodDef callEntries[] = {
32  CALLDEF(Class__name,1),
33  CALLDEF(Class__has_default_constructor,1),
34 
35  CALLDEF(CppClass__complete,1),
36  CALLDEF(CppClass__methods,1),
37 
38  CALLDEF(CppObject__finalize,2),
39 
40  CALLDEF(Module__classes_info,1),
41  CALLDEF(Module__complete,1),
42  CALLDEF(Module__get_class,2),
43  CALLDEF(Module__has_class,2),
44  CALLDEF(Module__has_function,2),
45  CALLDEF(Module__functions_arity,1),
46  CALLDEF(Module__functions_names,1),
47  CALLDEF(Module__name,1),
48  CALLDEF(Module__get_function, 2),
49 
53 
54  CALLDEF(CppField__get,3),
55  CALLDEF(CppField__set,4),
56 
60 
62  {NULL, NULL, 0}
63 };
64 
65 static R_ExternalMethodDef extEntries[] = {
73 
74  {NULL, NULL, 0}
75 };
76 
77 // this is called by R_init_Rcpp that is in Module.cpp
78 void init_Rcpp_routines(DllInfo *info){
79  // Register routines, allocate resources.
80  R_registerRoutines(info,
81  NULL, // .C
82  callEntries, // .Call
83  NULL, // .Fortran
84  extEntries // .External
85  );
86 }
87 
89  using namespace Rcpp;
90  using namespace Rcpp::internal;
91 
92  #define RCPP_REGISTER(__FUN__) R_RegisterCCallable( "Rcpp", #__FUN__ , (DL_FUNC)__FUN__ );
123  // RCPP_REGISTER(print)
130  #undef RCPP_REGISTER
131 }
132 
133 extern "C" void R_unload_Rcpp(DllInfo *) { // #nocov start
134  Rcpp::Rcpp_precious_teardown(); // release resource
135 } // #nocov end
136 
137 extern "C" void R_init_Rcpp(DllInfo* dllinfo) {
138  setCurrentScope(0);
139 
140  registerFunctions(); // call wrapper to register export symbols
141 
142  R_useDynamicSymbols(dllinfo, FALSE); // set up symbol symbol lookup (cf R 3.4.0)
143 
144  init_Rcpp_cache(); // init the cache
145 
147 
148  init_Rcpp_routines(dllinfo); // init routines
149 }
SEXP as_character_externalptr(SEXP xp)
Definition: api.cpp:160
SEXP rcpp_capabilities()
Definition: api.cpp:167
SEXP getRcppVersionStrings()
Definition: api.cpp:289
SEXP rcpp_can_use_cxx11()
Definition: api.cpp:265
SEXP rcpp_can_use_cxx0x()
Definition: api.cpp:255
SEXP init_Rcpp_cache()
Definition: barrier.cpp:177
SEXP get_rcpp_cache()
Definition: barrier.cpp:133
SEXP rcpp_error_recorder(SEXP e)
Definition: barrier.cpp:219
SEXP get_vector_elt(SEXP, R_xlen_t)
Definition: routines.h:240
const char * char_nocheck(SEXP)
Definition: routines.h:258
void set_vector_elt(SEXP, R_xlen_t, SEXP)
Definition: routines.h:246
void set_string_elt(SEXP, R_xlen_t, SEXP)
Definition: routines.h:222
SEXP * get_vector_ptr(SEXP)
Definition: routines.h:252
SEXP * get_string_ptr(SEXP)
Definition: routines.h:234
SEXP get_string_elt(SEXP, R_xlen_t)
Definition: routines.h:210
void char_set_string_elt(SEXP, R_xlen_t, const char *)
Definition: routines.h:228
const char * char_get_string_elt(SEXP, R_xlen_t)
Definition: routines.h:216
void * dataptr(SEXP)
Definition: routines.h:264
std::string demangle(const std::string &name)
Definition: routines.h:192
SEXP CppMethod__invoke_void(SEXP args)
Definition: module.cpp:185
SEXP CppMethod__invoke(SEXP args)
Definition: module.cpp:166
SEXP InternalFunction_invoke(SEXP args)
Definition: module.cpp:117
SEXP CppMethod__invoke_notvoid(SEXP args)
Definition: module.cpp:204
SEXP class__dummyInstance(SEXP args)
Definition: module.cpp:152
SEXP Module__invoke(SEXP args)
Definition: module.cpp:126
SEXP class__newInstance(SEXP args)
Definition: module.cpp:137
std::string short_file_name(const char *file)
Definition: macros.h:31
internal implementation details
Definition: Date.h:43
attribute_hidden unsigned long exitRNGScope()
Definition: routines.h:97
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
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
attribute_hidden void Rcpp_precious_remove(SEXP token)
Definition: routines.h:157
attribute_hidden void Rcpp_precious_teardown()
Definition: routines.h:147
void R_init_Rcpp(DllInfo *dllinfo)
Definition: rcpp_init.cpp:137
void registerFunctions()
Definition: rcpp_init.cpp:88
#define RCPP_REGISTER(__FUN__)
void R_unload_Rcpp(DllInfo *)
Definition: rcpp_init.cpp:133
#define CALLDEF(name, n)
Definition: rcpp_init.cpp:28
#define EXTDEF(name)
Definition: rcpp_init.cpp:29
static R_CallMethodDef callEntries[]
Definition: rcpp_init.cpp:31
void init_Rcpp_routines(DllInfo *info)
Definition: rcpp_init.cpp:78
static R_ExternalMethodDef extEntries[]
Definition: rcpp_init.cpp:65
attribute_hidden SEXP rcpp_set_stack_trace(SEXP e)
Definition: routines.h:186
attribute_hidden Rcpp::Module * getCurrentScope()
Definition: routines.h:270
attribute_hidden SEXP rcpp_get_current_error()
Definition: routines.h:300
attribute_hidden SEXP stack_trace(const char *file="", int line=-1)
Definition: routines.h:204
attribute_hidden int * get_cache(int n)
Definition: routines.h:282
attribute_hidden int error_occured()
Definition: routines.h:294
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