Rcpp Version 1.0.7
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 }
demangle
std::string demangle(const std::string &name)
Definition: routines.h:192
R_init_Rcpp
void R_init_Rcpp(DllInfo *dllinfo)
Definition: rcpp_init.cpp:137
getCurrentScope
attribute_hidden Rcpp::Module * getCurrentScope()
Definition: routines.h:270
getRcppVersionStrings
SEXP getRcppVersionStrings()
Definition: api.cpp:289
get_cache
attribute_hidden int * get_cache(int n)
Definition: routines.h:282
Rcpp::mktime00
attribute_hidden double mktime00(struct tm &tm)
Definition: routines.h:130
Rcpp::internal
internal implementation details
Definition: Date.h:43
get_string_ptr
SEXP * get_string_ptr(SEXP)
Definition: routines.h:234
Rcpp::internal::endSuspendRNGSynchronization
attribute_hidden unsigned long endSuspendRNGSynchronization()
Definition: routines.h:109
Rcpp::Rcpp_precious_preserve
attribute_hidden SEXP Rcpp_precious_preserve(SEXP object)
Definition: routines.h:152
CppMethod__invoke_void
SEXP CppMethod__invoke_void(SEXP args)
Definition: module.cpp:185
get_vector_ptr
SEXP * get_vector_ptr(SEXP)
Definition: routines.h:252
Rcpp::Rcpp_precious_remove
attribute_hidden void Rcpp_precious_remove(SEXP token)
Definition: routines.h:157
CppMethod__invoke_notvoid
SEXP CppMethod__invoke_notvoid(SEXP args)
Definition: module.cpp:204
rcpp_can_use_cxx11
SEXP rcpp_can_use_cxx11()
Definition: api.cpp:265
Rcpp::internal::get_string_buffer
attribute_hidden char * get_string_buffer()
Definition: routines.h:115
init_Rcpp_cache
SEXP init_Rcpp_cache()
Definition: barrier.cpp:176
char_nocheck
const char * char_nocheck(SEXP)
Definition: routines.h:258
rcpp_get_current_error
attribute_hidden SEXP rcpp_get_current_error()
Definition: routines.h:300
Rcpp::internal::exitRNGScope
attribute_hidden unsigned long exitRNGScope()
Definition: routines.h:97
Rcpp::internal::beginSuspendRNGSynchronization
attribute_hidden unsigned long beginSuspendRNGSynchronization()
Definition: routines.h:103
reset_current_error
attribute_hidden SEXP reset_current_error()
Definition: routines.h:288
rcpp_set_stack_trace
attribute_hidden SEXP rcpp_set_stack_trace(SEXP e)
Definition: routines.h:186
setCurrentScope
attribute_hidden void setCurrentScope(Rcpp::Module *mod)
Definition: routines.h:276
class__newInstance
SEXP class__newInstance(SEXP args)
Definition: module.cpp:137
InternalFunction_invoke
SEXP InternalFunction_invoke(SEXP args)
Definition: module.cpp:117
CALLDEF
#define CALLDEF(name, n)
Definition: rcpp_init.cpp:28
R_unload_Rcpp
void R_unload_Rcpp(DllInfo *)
Definition: rcpp_init.cpp:133
as_character_externalptr
SEXP as_character_externalptr(SEXP xp)
Definition: api.cpp:160
init_Rcpp_routines
void init_Rcpp_routines(DllInfo *info)
Definition: rcpp_init.cpp:78
class__dummyInstance
SEXP class__dummyInstance(SEXP args)
Definition: module.cpp:152
set_vector_elt
void set_vector_elt(SEXP, R_xlen_t, SEXP)
Definition: routines.h:246
extEntries
static R_ExternalMethodDef extEntries[]
Definition: rcpp_init.cpp:65
CppMethod__invoke
SEXP CppMethod__invoke(SEXP args)
Definition: module.cpp:166
Rcpp
Rcpp API.
Definition: algo.h:28
rcpp_capabilities
SEXP rcpp_capabilities()
Definition: api.cpp:167
dataptr
void * dataptr(SEXP)
Definition: routines.h:264
registerFunctions
void registerFunctions()
Definition: rcpp_init.cpp:88
Rcpp::type2name
attribute_hidden const char * type2name(SEXP x)
Definition: routines.h:84
Rcpp::Rcpp_cerr_get
attribute_hidden Rostream< false > & Rcpp_cerr_get()
Definition: routines.h:168
Rcpp::internal::get_Rcpp_namespace
attribute_hidden SEXP get_Rcpp_namespace()
Definition: routines.h:121
rcpp_can_use_cxx0x
SEXP rcpp_can_use_cxx0x()
Definition: api.cpp:255
stack_trace
attribute_hidden SEXP stack_trace(const char *file="", int line=-1)
Definition: routines.h:204
error_occured
attribute_hidden int error_occured()
Definition: routines.h:294
Rcpp::gmtime_
attribute_hidden struct tm * gmtime_(const time_t *const x)
Definition: routines.h:136
internal.h
char_get_string_elt
const char * char_get_string_elt(SEXP, R_xlen_t)
Definition: routines.h:216
Rcpp::Rcpp_precious_init
attribute_hidden void Rcpp_precious_init()
Definition: routines.h:142
EXTDEF
#define EXTDEF(name)
Definition: rcpp_init.cpp:29
rcpp_error_recorder
SEXP rcpp_error_recorder(SEXP e)
Definition: barrier.cpp:218
set_string_elt
void set_string_elt(SEXP, R_xlen_t, SEXP)
Definition: routines.h:222
callEntries
static R_CallMethodDef callEntries[]
Definition: rcpp_init.cpp:31
rcpp_get_stack_trace
attribute_hidden SEXP rcpp_get_stack_trace()
Definition: routines.h:180
Rcpp::Rcpp_cout_get
attribute_hidden Rostream< true > & Rcpp_cout_get()
Definition: routines.h:163
Rcpp::Rcpp_precious_teardown
attribute_hidden void Rcpp_precious_teardown()
Definition: routines.h:147
char_set_string_elt
void char_set_string_elt(SEXP, R_xlen_t, const char *)
Definition: routines.h:228
Rcpp::internal::debug::short_file_name
std::string short_file_name(const char *file)
Definition: macros.h:31
Module__invoke
SEXP Module__invoke(SEXP args)
Definition: module.cpp:126
Rcpp.h
get_string_elt
SEXP get_string_elt(SEXP, R_xlen_t)
Definition: routines.h:210
Rcpp::internal::enterRNGScope
attribute_hidden unsigned long enterRNGScope()
Definition: routines.h:91
get_rcpp_cache
SEXP get_rcpp_cache()
Definition: barrier.cpp:132
get_vector_elt
SEXP get_vector_elt(SEXP, R_xlen_t)
Definition: routines.h:240
RCPP_REGISTER
#define RCPP_REGISTER(__FUN__)