[Rcpp-commits] r2650 - in pkg/Rcpp: inst/unitTests src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Dec 2 10:29:21 CET 2010
Author: romain
Date: 2010-12-02 10:29:19 +0100 (Thu, 02 Dec 2010)
New Revision: 2650
Added:
pkg/Rcpp/src/classic.cpp
Modified:
pkg/Rcpp/inst/unitTests/runTests.R
pkg/Rcpp/inst/unitTests/runit.Module.R
pkg/Rcpp/inst/unitTests/runit.RcppResultSet.R
pkg/Rcpp/inst/unitTests/runit.S4.R
pkg/Rcpp/inst/unitTests/runit.Vector.R
pkg/Rcpp/inst/unitTests/runit.XPTr.R
pkg/Rcpp/inst/unitTests/runit.macros.R
Log:
adding deprecation hooks (8)
Modified: pkg/Rcpp/inst/unitTests/runTests.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runTests.R 2010-12-02 09:01:33 UTC (rev 2649)
+++ pkg/Rcpp/inst/unitTests/runTests.R 2010-12-02 09:29:19 UTC (rev 2650)
@@ -27,10 +27,6 @@
stop( "Rcpp unit tests need at least the version 0.3.4.4 of inline" )
}
-cppfunction <- function(...){
- cxxfunction( ..., plugin = "Rcpp" )
-}
-
if(require("RUnit", quietly = TRUE)) {
is_local <- function(){
Modified: pkg/Rcpp/inst/unitTests/runit.Module.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Module.R 2010-12-02 09:01:33 UTC (rev 2649)
+++ pkg/Rcpp/inst/unitTests/runit.Module.R 2010-12-02 09:29:19 UTC (rev 2650)
@@ -78,7 +78,7 @@
class_<World>( "World" )
- .default_constructor()
+ .constructor()
.method( "greet", &World::greet )
.method( "set", &World::set )
@@ -136,7 +136,7 @@
class_<vec>( "vec")
- .default_constructor()
+ .constructor()
.method( "size", &vec::size)
.method( "max_size", &vec::max_size)
@@ -198,7 +198,7 @@
class_<Num>( "Num" )
- .default_constructor()
+ .constructor()
// read and write property
.property( "x", &Num::getX, &Num::setX )
@@ -239,7 +239,7 @@
class_<Number>( "Number" )
- .default_constructor()
+ .constructor()
// read and write data member
.field( "x", &Number::x )
Modified: pkg/Rcpp/inst/unitTests/runit.RcppResultSet.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.RcppResultSet.R 2010-12-02 09:01:33 UTC (rev 2649)
+++ pkg/Rcpp/inst/unitTests/runit.RcppResultSet.R 2010-12-02 09:29:19 UTC (rev 2650)
@@ -360,7 +360,7 @@
RcppResultSet rs;
rs.add("", iv);
return(rs.getSEXP());'
- funx <- cppfunction(signature(x="numeric"), foo )
+ funx <- cxxfunction(signature(x="numeric"), foo, plugin = "Rcpp" )
checkEquals( funx(x=2:5), 2:5*2L, msg = "as<std::vector<int> >(integer) via RcppResultSet" )
checkEquals( funx(x=2:5+.1), 2:5*2L, msg = "as<std::vector<int> >(numeric) via RcppResultSet" )
checkEquals( funx(x=as.raw(2:5)), 2:5*2L, msg = "as<std::vector<int> >(raw) via RcppResultSet" )
Modified: pkg/Rcpp/inst/unitTests/runit.S4.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.S4.R 2010-12-02 09:01:33 UTC (rev 2649)
+++ pkg/Rcpp/inst/unitTests/runit.S4.R 2010-12-02 09:29:19 UTC (rev 2650)
@@ -129,8 +129,8 @@
setClass("track",
representation(x="numeric", y="numeric"))
tr <- new( "track", x = 2, y = 3 )
- fx <- cppfunction( signature( x = "ANY" ),
- 'S4 o(x); return o.slot( "x" ) ;')
+ fx <- cxxfunction( signature( x = "ANY" ),
+ 'S4 o(x); return o.slot( "x" ) ;', plugin = "Rcpp" )
checkEquals( fx( tr ), 2, msg = "S4( SEXP )" )
checkException( fx( list( x = 2, y = 3 ) ), msg = "not S4" )
Modified: pkg/Rcpp/inst/unitTests/runit.Vector.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Vector.R 2010-12-02 09:01:33 UTC (rev 2649)
+++ pkg/Rcpp/inst/unitTests/runit.Vector.R 2010-12-02 09:29:19 UTC (rev 2650)
@@ -1005,13 +1005,13 @@
# test.List.insert <- function(){
#
-# funx <- cppfunction( signature(x = "list"),
+# funx <- cxxfunction( signature(x = "list"),
# '
# List list(x) ;
# list.insert( list.begin(), 10 ) ;
# list.insert( list.end(), Named("foo", "bar" ) ) ;
# return list ;
-# ' )
+# ' , plugin = "Rcpp" )
# d <- list( x = 1:10, y = letters[1:10] )
# res <- funx( d )
# checkEquals( res,
Modified: pkg/Rcpp/inst/unitTests/runit.XPTr.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.XPTr.R 2010-12-02 09:01:33 UTC (rev 2649)
+++ pkg/Rcpp/inst/unitTests/runit.XPTr.R 2010-12-02 09:29:19 UTC (rev 2650)
@@ -19,7 +19,7 @@
test.XPtr <- function(){
- funx <- cppfunction(signature(), '
+ funx <- cxxfunction(signature(), '
/* creating a pointer to a vector<int> */
std::vector<int>* v = new std::vector<int> ;
v->push_back( 1 ) ;
@@ -34,13 +34,13 @@
the external pointer is no more protected by p, but it gets
protected by being on the R side */
return( p ) ;
- ')
+ ', plugin = "Rcpp" )
xp <- funx()
checkEquals( typeof( xp ), "externalptr",
msg = "checking external pointer creation" )
# passing the pointer back to C++
- funx <- cppfunction(signature(x = "externalptr" ), '
+ funx <- cxxfunction(signature(x = "externalptr" ), '
/* wrapping x as smart external pointer */
/* The SEXP based constructor does not protect the SEXP from
garbage collection automatically, it is already protected
@@ -52,7 +52,7 @@
/* just return the front of the vector as a SEXP */
return( Rcpp::wrap( p->front() ) ) ;
- ')
+ ', plugin = "Rcpp" )
front <- funx(xp)
checkEquals( front, 1L, msg = "check usage of external pointer" )
}
Modified: pkg/Rcpp/inst/unitTests/runit.macros.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.macros.R 2010-12-02 09:01:33 UTC (rev 2649)
+++ pkg/Rcpp/inst/unitTests/runit.macros.R 2010-12-02 09:29:19 UTC (rev 2650)
@@ -60,13 +60,13 @@
test.RCPPFUNCTION <- function(){
- fx <- cppfunction( signature(), '
+ fx <- cxxfunction( signature(), '
return foo() ;
', includes = '
RCPP_FUNCTION_0(int, foo){
return 10 ;
}
- ')
+ ', plugin = "Rcpp" )
checkEquals( fx(), 10L, msg = "RCPP_FUNCTION_0" )
checkEquals( .getInfo( "foo", fx ) ,
@@ -75,13 +75,13 @@
output = "int",
input = character(0) ), class = "rcppfunctioninfo" ) )
- fx <- cppfunction( signature(x = "numeric", y = "numeric" ), '
+ fx <- cxxfunction( signature(x = "numeric", y = "numeric" ), '
return foo(x, y) ;
', includes = '
RCPP_FUNCTION_2(double, foo, double x, double y){
return x * y ;
}
- ')
+ ', plugin = "Rcpp" )
checkEquals( fx( 10, 10), 100, msg = "RCPP_FUNCTION_2" )
checkEquals( .getInfo( "foo", fx ) ,
@@ -93,13 +93,13 @@
}
test.RCPPFUNCTION.VOID <- function(){
- fx <- cppfunction( signature(), '
+ fx <- cxxfunction( signature(), '
return foo() ;
', includes = '
RCPP_FUNCTION_VOID_0(foo){
Rprintf("hello\\n") ;
}
- ')
+ ', plugin = "Rcpp" )
checkEquals( capture.output( x <- fx() ) , "hello", 10L, msg = "RCPP_FUNCTION_VOID_0" )
info <- .getInfo( "foo", fx )
@@ -108,13 +108,13 @@
checkEquals( info[["output"]], NULL)
checkEquals( class(info), "rcppfunctionvoidinfo" )
- fx <- cppfunction( signature(x = "character", y = "integer" ), '
+ fx <- cxxfunction( signature(x = "character", y = "integer" ), '
return foo(x, y) ;
', includes = '
RCPP_FUNCTION_VOID_2(foo, std::string x, int y){
Rprintf("hello %s (%d)\\n", x.c_str(), y) ;
}
- ')
+ ', plugin = "Rcpp" )
checkEquals( capture.output( x <- fx("world", 3L) ) , "hello world (3)", 10L, msg = "RCPP_FUNCTION_VOID_0" )
info <- .getInfo( "foo", fx )
@@ -127,18 +127,18 @@
test.RCPPXPMETHOD <- function(){
- fx <- cppfunction( signature(), '
+ fx <- cxxfunction( signature(), '
std::vector<int>* v = new std::vector<int>(5) ;
v->push_back( 5 ) ;
return XPtr< std::vector<int> >(v,true) ;
- ' )
+ ' , plugin = "Rcpp" )
xp <- fx()
- f_back <- cppfunction( signature( xp = "externalptr" ), '
+ f_back <- cxxfunction( signature( xp = "externalptr" ), '
return get_back( xp ) ;
', includes = '
RCPP_XP_METHOD_0( get_back, std::vector<int>, back )
- ' )
+ ', plugin = "Rcpp" )
checkEquals( f_back(xp), 5L, msg = "RCPP_XP_METHOD_0" )
info <- .getInfo( "get_back", f_back )
@@ -147,12 +147,12 @@
checkEquals( info[["method"]], "back")
checkEquals( class(info), "rcppxpmethodinfo" )
- f_push_back <- cppfunction( signature( xp = "externalptr", x = "integer" ), '
+ f_push_back <- cxxfunction( signature( xp = "externalptr", x = "integer" ), '
vec_push_back( xp, x );
return R_NilValue ;
', includes = '
RCPP_XP_METHOD_VOID_1( vec_push_back, std::vector<int>, push_back )
- ' )
+ ' , plugin = "Rcpp" )
f_push_back( xp, 10L )
checkEquals( f_back(xp), 10L, msg = "RCPP_XP_METHOD_0" )
f_push_back( xp, 20L )
@@ -165,11 +165,11 @@
checkEquals( class(info), "rcppxpmethodvoidinfo" )
- f_front_cast <- cppfunction( signature( xp = "externalptr" ), '
+ f_front_cast <- cxxfunction( signature( xp = "externalptr" ), '
return front( xp ) ;
', includes = '
RCPP_XP_METHOD_CAST_0( front, std::vector<int>, front, double )
- ' )
+ ' , plugin = "Rcpp" )
checkEquals( f_front_cast(xp), 0, msg = "RCPP_XP_METHOD_CAST value" )
checkEquals( typeof( f_front_cast(xp) ), "double", msg = "RCPP_XP_METHOD_CAST type" )
@@ -197,7 +197,7 @@
}
'
- fx <- cppfunction( signature(xp = "externalptr"), '', include = cl )
+ fx <- cxxfunction( signature(xp = "externalptr"), '', include = cl, plugin = "Rcpp" )
get_info <- .getInfo( "Foo_x_get", fx )
set_info <- .getInfo( "Foo_x_set", fx )
@@ -220,14 +220,14 @@
### regression test for long long support
test.long.long <- function(){
- fx <- cppfunction( signature(), '
+ fx <- cxxfunction( signature(), '
return foo() ;
', includes = '
RCPP_FUNCTION_0(size_t, foo){
std::vector<int> v(10) ;
return v.size() ;
}
- ')
+ ', plugin = "Rcpp" )
checkEquals( as.integer(fx()), 10L, msg = "long long support" )
}
Added: pkg/Rcpp/src/classic.cpp
===================================================================
--- pkg/Rcpp/src/classic.cpp (rev 0)
+++ pkg/Rcpp/src/classic.cpp 2010-12-02 09:29:19 UTC (rev 2650)
@@ -0,0 +1,43 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// classic.cpp: Rcpp R/C++ interface class library -- classic api bootstrap
+//
+// Copyright (C) 2010 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/>.
+
+#include <deprecation.h>
+#ifndef RCPP_NO_CLASSIC_API
+
+#include "deprecated/copyMessageToR.cpp"
+#include "deprecated/RcppDate.cpp"
+#include "deprecated/RcppDateVector.cpp"
+#include "deprecated/RcppDatetime.cpp"
+#include "deprecated/RcppDatetimeVector.cpp"
+#include "deprecated/RcppFrame.cpp"
+#include "deprecated/RcppFunction.cpp"
+#include "deprecated/RcppList.cpp"
+#include "deprecated/RcppNumList.cpp"
+#include "deprecated/RcppParams.cpp"
+#include "deprecated/RcppResultSet.cpp"
+#include "deprecated/RcppStringVector.cpp"
+#include "deprecated/RcppStringVectorView.cpp"
+
+#else
+// silencing the compiler
+void classic_api_dummy(){}
+#endif
+
More information about the Rcpp-commits
mailing list