|
Rcpp Version 0.9.10
|
00001 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 00002 // 00003 // Rcpp_init.c : Rcpp R/C++ interface class library -- Initialize and register 00004 // 00005 // Copyright (C) 2010 - 2011 John Chambers, Dirk Eddelbuettel and Romain Francois 00006 // 00007 // This file is part of Rcpp. 00008 // 00009 // Rcpp is free software: you can redistribute it and/or modify it 00010 // under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation, either version 2 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // Rcpp is distributed in the hope that it will be useful, but 00015 // WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>. 00021 #include <R.h> 00022 #include <Rinternals.h> 00023 #include <R_ext/Rdynload.h> 00024 00025 #include <Rcpp/routines.h> 00026 00027 // borrowed from Matrix 00028 #define CALLDEF(name, n) {#name, (DL_FUNC) &name, n} 00029 #define EXTDEF(name) {#name, (DL_FUNC) &name, -1} 00030 00031 00032 // TODO: check that having this static does not mess up with 00033 // RInside, and move it within init_Rcpp_routines otherwise 00034 static R_CallMethodDef callEntries[] = { 00035 CALLDEF(as_character_externalptr,1), 00036 00037 CALLDEF(CppField__get,3), 00038 CALLDEF(CppField__set,4), 00039 00040 CALLDEF(Class__name,1), 00041 CALLDEF(Class__has_default_constructor,1), 00042 00043 CALLDEF(CppClass__complete,1), 00044 CALLDEF(CppClass__methods,1), 00045 00046 CALLDEF(CppObject__finalize,2), 00047 00048 CALLDEF(Module__classes_info,1), 00049 CALLDEF(Module__complete,1), 00050 CALLDEF(Module__get_class,2), 00051 CALLDEF(Module__has_class,2), 00052 CALLDEF(Module__has_function,2), 00053 CALLDEF(Module__functions_arity,1), 00054 CALLDEF(Module__functions_names,1), 00055 CALLDEF(Module__name,1), 00056 CALLDEF(Module__get_function, 2), 00057 00058 CALLDEF(get_rcpp_cache,0), 00059 // CALLDEF(init_Rcpp_cache,0), 00060 CALLDEF(reset_current_error,0), 00061 CALLDEF(rcpp_error_recorder,1), 00062 CALLDEF(rcpp_set_current_error,1), 00063 CALLDEF(rcpp_get_current_error,0), 00064 CALLDEF(rcpp_set_error_occured,1), 00065 CALLDEF(rcpp_get_error_occured,0), 00066 CALLDEF(rcpp_set_stack_trace,1), 00067 CALLDEF(rcpp_get_stack_trace,0), 00068 00069 {NULL, NULL, 0} 00070 }; 00071 00072 static R_ExternalMethodDef extEntries[] = { 00073 EXTDEF(CppMethod__invoke), 00074 EXTDEF(CppMethod__invoke_void), 00075 EXTDEF(CppMethod__invoke_notvoid), 00076 EXTDEF(InternalFunction_invoke), 00077 EXTDEF(Module__invoke), 00078 EXTDEF(class__newInstance), 00079 EXTDEF(class__dummyInstance), 00080 00081 {NULL, NULL, 0} 00082 } ; 00083 00084 // this is called by R_init_Rcpp that is in Module.cpp 00085 void init_Rcpp_routines(DllInfo *info){ 00086 /* Register routines, allocate resources. */ 00087 R_registerRoutines(info, 00088 NULL /* .C*/, 00089 callEntries /*.Call*/, 00090 NULL /* .Fortran */, 00091 extEntries /*.External*/ 00092 ); 00093 } 00094 00095 void R_unload_Rcpp(DllInfo *info) { 00096 /* Release resources. */ 00097 }