[Rcpp-commits] r4127 - in pkg/Rcpp: inst/include inst/include/Rcpp inst/include/Rcpp/macros src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Dec 10 13:23:49 CET 2012
Author: romain
Date: 2012-12-10 13:23:49 +0100 (Mon, 10 Dec 2012)
New Revision: 4127
Added:
pkg/Rcpp/inst/include/Rcpp/macros/macros.h
Modified:
pkg/Rcpp/inst/include/Rcpp/RObject.h
pkg/Rcpp/inst/include/Rcpp/routines.h
pkg/Rcpp/inst/include/RcppCommon.h
pkg/Rcpp/src/Module.cpp
pkg/Rcpp/src/Rcpp_init.c
pkg/Rcpp/src/exceptions.cpp
pkg/Rcpp/src/internal.h
Log:
more moving things out of Rcpp.h
Modified: pkg/Rcpp/inst/include/Rcpp/RObject.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/RObject.h 2012-12-10 11:52:53 UTC (rev 4126)
+++ pkg/Rcpp/inst/include/Rcpp/RObject.h 2012-12-10 12:23:49 UTC (rev 4127)
@@ -24,7 +24,7 @@
#define R_NO_REMAP
#include <R.h>
-#include <Rcpp/macros/debug.h>
+#include <Rcpp/macros/macros.h>
#include <Rinternals.h>
#include <vector>
#include <string>
Added: pkg/Rcpp/inst/include/Rcpp/macros/macros.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/macros/macros.h (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/macros/macros.h 2012-12-10 12:23:49 UTC (rev 4127)
@@ -0,0 +1,31 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
+//
+// macros.h: Rcpp R/C++ interface class library -- Rcpp macros
+//
+// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois
+//
+// 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_macros_macros_h
+#define Rcpp_macros_macros_h
+
+#include <Rcpp/macros/debug.h>
+#include <Rcpp/macros/unroll.h>
+
+#define RCPP_GET_NAMES(x) Rf_getAttrib(x, R_NamesSymbol)
+#define RCPP_GET_CLASS(x) Rf_getAttrib(x, R_ClassSymbol)
+
+#endif
Modified: pkg/Rcpp/inst/include/Rcpp/routines.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/routines.h 2012-12-10 11:52:53 UTC (rev 4126)
+++ pkg/Rcpp/inst/include/Rcpp/routines.h 2012-12-10 12:23:49 UTC (rev 4127)
@@ -36,10 +36,6 @@
extern "C" {
#endif
-CALLFUN_1(as_character_externalptr) ;
-
-CALLFUN_3(CppField__get);
-CALLFUN_4(CppField__set);
CALLFUN_1(Class__name);
CALLFUN_1(Class__has_default_constructor) ;
CALLFUN_1(CppClass__complete);
Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h 2012-12-10 11:52:53 UTC (rev 4126)
+++ pkg/Rcpp/inst/include/RcppCommon.h 2012-12-10 12:23:49 UTC (rev 4127)
@@ -26,7 +26,7 @@
#include <Rcpp/platform/compiler.h>
#include <Rcpp/config.h>
-#include <Rcpp/macros/unroll.h>
+#include <Rcpp/macros/macros.h>
void logTxtFunction(const char* file, const int line, const char* expression ) ;
@@ -77,7 +77,6 @@
#include <R_ext/Parse.h>
#include <R_ext/Rdynload.h>
#include <Rversion.h>
-#define RCPP_GET_NAMES(x) Rf_getAttrib(x, R_NamesSymbol)
inline SEXP Rcpp_lcons(SEXP car, SEXP cdr){
PROTECT(car) ;
@@ -93,10 +92,6 @@
#define RcppExport extern "C"
-RcppExport void init_Rcpp_routines(DllInfo*) ;
-
-const char * sexp_to_name(int sexp_type);
-
#include <Rcpp/exceptions.h>
namespace Rcpp{
@@ -115,8 +110,6 @@
} // namespace Rcpp
-#include <Rcpp/macros/debug.h>
-
#define Rcpp_error(MESSAGE) throw Rcpp::exception( MESSAGE, __FILE__, __LINE__ )
namespace Rcpp {
Modified: pkg/Rcpp/src/Module.cpp
===================================================================
--- pkg/Rcpp/src/Module.cpp 2012-12-10 11:52:53 UTC (rev 4126)
+++ pkg/Rcpp/src/Module.cpp 2012-12-10 12:23:49 UTC (rev 4127)
@@ -20,9 +20,19 @@
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
#include <Rcpp.h>
+#include "internal.h"
#define MAX_ARGS 65
+#define UNPACK_EXTERNAL_ARGS(__CARGS__,__P__) \
+SEXP __CARGS__[MAX_ARGS] ; \
+int nargs = 0 ; \
+for(; nargs<MAX_ARGS; nargs++){ \
+ if( p == R_NilValue ) break ; \
+ __CARGS__[nargs] = CAR(__P__) ; \
+ __P__ = CDR(__P__) ; \
+}
+
typedef Rcpp::XPtr<Rcpp::Module> XP_Module ;
typedef Rcpp::XPtr<Rcpp::class_Base> XP_Class ;
typedef Rcpp::XPtr<Rcpp::CppFunction> XP_Function ;
@@ -117,15 +127,8 @@
BEGIN_RCPP
SEXP p = CDR(args) ;
XP_Function fun( CAR(p) ) ; p = CDR(p) ;
-
- SEXP cargs[MAX_ARGS] ;
- int nargs = 0 ;
- for(; nargs<MAX_ARGS; nargs++){
- if( p == R_NilValue ) break ;
- cargs[nargs] = CAR(p) ;
- p = CDR(p) ;
- }
- return fun->operator()( cargs ) ;
+ UNPACK_EXTERNAL_ARGS(cargs,p)
+ return fun->operator()( cargs ) ;
END_RCPP
}
@@ -135,14 +138,8 @@
XP_Module module( CAR(p) ) ; p = CDR(p) ;
std::string fun = Rcpp::as<std::string>( CAR(p) ) ; p = CDR(p) ;
- SEXP cargs[MAX_ARGS] ;
- int nargs = 0 ;
- for(; nargs<MAX_ARGS; nargs++){
- if( p == R_NilValue ) break ;
- cargs[nargs] = CAR(p) ;
- p = CDR(p) ;
- }
- return module->invoke( fun, cargs, nargs ) ;
+ UNPACK_EXTERNAL_ARGS(cargs,p)
+ return module->invoke( fun, cargs, nargs ) ;
END_RCPP
}
@@ -151,14 +148,8 @@
XP_Module module( CAR(p) ) ; p = CDR(p) ;
XP_Class clazz( CAR(p) ) ; p = CDR(p);
- SEXP cargs[MAX_ARGS] ;
- int nargs = 0 ;
- for(; nargs<MAX_ARGS; nargs++){
- if( p == R_NilValue ) break ;
- cargs[nargs] = CAR(p) ;
- p = CDR(p) ;
- }
- return clazz->newInstance(cargs, nargs ) ;
+ UNPACK_EXTERNAL_ARGS(cargs,p)
+ return clazz->newInstance(cargs, nargs ) ;
}
SEXP rcpp_dummy_pointer = R_NilValue; // relies on being set in .onLoad()
@@ -193,14 +184,8 @@
CHECK_DUMMY_OBJ(obj);
// additional arguments, processed the same way as .Call does
- SEXP cargs[MAX_ARGS] ;
- int nargs = 0 ;
- for(; nargs<MAX_ARGS; nargs++){
- if( p == R_NilValue ) break ;
- cargs[nargs] = CAR(p) ;
- p = CDR(p) ;
- }
-
+ UNPACK_EXTERNAL_ARGS(cargs,p)
+
return clazz->invoke( met, obj, cargs, nargs ) ;
}
@@ -218,14 +203,8 @@
CHECK_DUMMY_OBJ(obj);
// additional arguments, processed the same way as .Call does
- SEXP cargs[MAX_ARGS] ;
- int nargs = 0 ;
- for(; nargs<MAX_ARGS; nargs++){
- if( p == R_NilValue ) break ;
- cargs[nargs] = CAR(p) ;
- p = CDR(p) ;
- }
- clazz->invoke_void( met, obj, cargs, nargs ) ;
+ UNPACK_EXTERNAL_ARGS(cargs,p)
+ clazz->invoke_void( met, obj, cargs, nargs ) ;
return R_NilValue ;
}
@@ -243,14 +222,8 @@
CHECK_DUMMY_OBJ(obj);
// additional arguments, processed the same way as .Call does
- SEXP cargs[MAX_ARGS] ;
- int nargs = 0 ;
- for(; nargs<MAX_ARGS; nargs++){
- if( p == R_NilValue ) break ;
- cargs[nargs] = CAR(p) ;
- p = CDR(p) ;
- }
-
+ UNPACK_EXTERNAL_ARGS(cargs,p)
+
return clazz->invoke_notvoid( met, obj, cargs, nargs ) ;
}
Modified: pkg/Rcpp/src/Rcpp_init.c
===================================================================
--- pkg/Rcpp/src/Rcpp_init.c 2012-12-10 11:52:53 UTC (rev 4126)
+++ pkg/Rcpp/src/Rcpp_init.c 2012-12-10 12:23:49 UTC (rev 4127)
@@ -33,11 +33,6 @@
// TODO: check that having this static does not mess up with
// RInside, and move it within init_Rcpp_routines otherwise
static R_CallMethodDef callEntries[] = {
- CALLDEF(as_character_externalptr,1),
-
- CALLDEF(CppField__get,3),
- CALLDEF(CppField__set,4),
-
CALLDEF(Class__name,1),
CALLDEF(Class__has_default_constructor,1),
@@ -65,7 +60,13 @@
CALLDEF(rcpp_set_stack_trace,1),
CALLDEF(rcpp_get_stack_trace,0),
- // functions that are not defined in Rcpp.h
+
+
+ CALLDEF(as_character_externalptr,1),
+
+ CALLDEF(CppField__get,3),
+ CALLDEF(CppField__set,4),
+
CALLDEF(rcpp_capabilities,0),
CALLDEF(rcpp_can_use_cxx0x,0),
CALLDEF(rcpp_call_test,1),
Modified: pkg/Rcpp/src/exceptions.cpp
===================================================================
--- pkg/Rcpp/src/exceptions.cpp 2012-12-10 11:52:53 UTC (rev 4126)
+++ pkg/Rcpp/src/exceptions.cpp 2012-12-10 12:23:49 UTC (rev 4127)
@@ -19,7 +19,7 @@
// You should have received a copy of the GNU General Public License
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
-#include <Rcpp/config.h>
+#include <Rcpp/platform/compiler.h>
#define R_NO_REMAP
#include <Rinternals.h>
#include <Rcpp/exceptions.h>
Modified: pkg/Rcpp/src/internal.h
===================================================================
--- pkg/Rcpp/src/internal.h 2012-12-10 11:52:53 UTC (rev 4126)
+++ pkg/Rcpp/src/internal.h 2012-12-10 12:23:49 UTC (rev 4127)
@@ -36,10 +36,18 @@
extern "C" {
#endif
+ CALLFUN_1(as_character_externalptr) ;
+
+ CALLFUN_3(CppField__get);
+ CALLFUN_4(CppField__set);
+
CALLFUN_0(rcpp_capabilities) ;
CALLFUN_0(rcpp_can_use_cxx0x) ;
CALLFUN_1(rcpp_call_test) ;
+ void init_Rcpp_routines(DllInfo*) ;
+ const char * sexp_to_name(int sexp_type);
+
#ifdef __cplusplus
}
#endif
More information about the Rcpp-commits
mailing list