Rcpp Version 0.12.12
Rcpp_init.cpp
Go to the documentation of this file.
1 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2 //
3 // Rcpp_init.cpp : Rcpp R/C++ interface class library -- Initialize and register
4 //
5 // Copyright (C) 2010 - 2017 John Chambers, Dirk Eddelbuettel and Romain Francois
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  {NULL, NULL, 0}
61 };
62 
63 static R_ExternalMethodDef extEntries[] = {
71 
72  {NULL, NULL, 0}
73 };
74 
75 // this is called by R_init_Rcpp that is in Module.cpp
76 void init_Rcpp_routines(DllInfo *info){
77  // Register routines, allocate resources.
78  R_registerRoutines(info,
79  NULL, // .C
80  callEntries, // .Call
81  NULL, // .Fortran
82  extEntries // .External
83  );
84 }
85 
87  using namespace Rcpp;
88  using namespace Rcpp::internal;
89 
90  #define RCPP_REGISTER(__FUN__) R_RegisterCCallable( "Rcpp", #__FUN__ , (DL_FUNC)__FUN__ );
119  // RCPP_REGISTER(print)
120  #undef RCPP_REGISTER
121 }
122 
123 
124 extern "C" void R_unload_Rcpp(DllInfo *) { // #nocov start
125  // Release resources
126 } // #nocov end
127 
128 extern "C" void R_init_Rcpp(DllInfo* dllinfo) {
129  setCurrentScope(0);
130 
131  registerFunctions(); // call wrapper to register export symbols
132 
133  R_useDynamicSymbols(dllinfo, FALSE); // set up symbol symbol lookup (cf R 3.4.0)
134 
135  init_Rcpp_cache(); // init the cache
136 
137  init_Rcpp_routines(dllinfo); // init routines
138 }
attribute_hidden void setCurrentScope(Rcpp::Module *mod)
Definition: routines.h:218
void R_init_Rcpp(DllInfo *dllinfo)
Definition: Rcpp_init.cpp:128
void R_unload_Rcpp(DllInfo *)
Definition: Rcpp_init.cpp:124
attribute_hidden double mktime00(struct tm &tm)
Definition: routines.h:104
SEXP as_character_externalptr(SEXP xp)
Definition: api.cpp:158
SEXP * get_string_ptr(SEXP)
Definition: routines.h:176
SEXP rcpp_capabilities()
Definition: api.cpp:165
#define RCPP_REGISTER(__FUN__)
SEXP * get_vector_ptr(SEXP)
Definition: routines.h:194
const char * char_nocheck(SEXP)
Definition: routines.h:200
SEXP get_vector_elt(SEXP, R_xlen_t)
Definition: routines.h:182
SEXP rcpp_error_recorder(SEXP e)
Definition: barrier.cpp:180
attribute_hidden SEXP stack_trace(const char *file="", int line=-1)
Definition: routines.h:146
SEXP class__newInstance(SEXP args)
Definition: Module.cpp:137
internal implementation details
Definition: Date.h:43
SEXP get_rcpp_cache()
Definition: barrier.cpp:94
SEXP CppMethod__invoke_void(SEXP args)
Definition: Module.cpp:185
void set_vector_elt(SEXP, R_xlen_t, SEXP)
Definition: routines.h:188
std::string demangle(const std::string &name)
Definition: routines.h:134
SEXP class__dummyInstance(SEXP args)
Definition: Module.cpp:152
static R_CallMethodDef callEntries[]
Definition: Rcpp_init.cpp:31
SEXP init_Rcpp_cache()
Definition: barrier.cpp:138
void * dataptr(SEXP)
Definition: routines.h:206
SEXP rcpp_can_use_cxx11()
Definition: api.cpp:263
static R_ExternalMethodDef extEntries[]
Definition: Rcpp_init.cpp:63
SEXP CppMethod__invoke(SEXP args)
Definition: Module.cpp:166
attribute_hidden SEXP reset_current_error()
Definition: routines.h:230
SEXP CppMethod__invoke_notvoid(SEXP args)
Definition: Module.cpp:204
attribute_hidden SEXP rcpp_get_current_error()
Definition: routines.h:242
void registerFunctions()
Definition: Rcpp_init.cpp:86
SEXP rcpp_can_use_cxx0x()
Definition: api.cpp:253
attribute_hidden unsigned long exitRNGScope()
Definition: routines.h:83
void init_Rcpp_routines(DllInfo *info)
Definition: Rcpp_init.cpp:76
attribute_hidden SEXP rcpp_set_stack_trace(SEXP e)
Definition: routines.h:128
attribute_hidden const char * type2name(SEXP x)
Definition: routines.h:70
SEXP InternalFunction_invoke(SEXP args)
Definition: Module.cpp:117
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
const char * char_get_string_elt(SEXP, R_xlen_t)
Definition: routines.h:158
#define CALLDEF(name, n)
Definition: Rcpp_init.cpp:28
attribute_hidden unsigned long enterRNGScope()
Definition: routines.h:77
void char_set_string_elt(SEXP, R_xlen_t, const char *)
Definition: routines.h:170
attribute_hidden char * get_string_buffer()
Definition: routines.h:89
SEXP get_string_elt(SEXP, R_xlen_t)
Definition: routines.h:152
attribute_hidden SEXP rcpp_get_stack_trace()
Definition: routines.h:122
attribute_hidden SEXP get_Rcpp_namespace()
Definition: routines.h:95
SEXP Module__invoke(SEXP args)
Definition: Module.cpp:126
void set_string_elt(SEXP, R_xlen_t, SEXP)
Definition: routines.h:164
Rcpp API.
Definition: algo.h:28
attribute_hidden const char * short_file_name(const char *file)
Definition: routines.h:140
#define EXTDEF(name)
Definition: Rcpp_init.cpp:29