[Rcpp-commits] r2468 - in pkg/Rcpp: R inst/include/Rcpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Nov 20 12:47:10 CET 2010


Author: romain
Date: 2010-11-20 12:47:09 +0100 (Sat, 20 Nov 2010)
New Revision: 2468

Modified:
   pkg/Rcpp/R/Module.R
   pkg/Rcpp/inst/include/Rcpp/Module.h
Log:
fixed weird interaction with [[

Modified: pkg/Rcpp/R/Module.R
===================================================================
--- pkg/Rcpp/R/Module.R	2010-11-19 17:37:18 UTC (rev 2467)
+++ pkg/Rcpp/R/Module.R	2010-11-20 11:47:09 UTC (rev 2468)
@@ -200,18 +200,20 @@
     module
 }
 
+dealWith <- function( x ) if(isTRUE(x[[1]])) invisible(NULL) else x[[2]]
+
 method_wrapper <- function( METHOD, where ){
             f <- function(...) NULL
 	    extCall <- substitute(
 	    {
-           res <- .External(CppMethod__invoke, class_pointer, pointer, .pointer, ...)
-           if(res[[1]]) invisible(NULL) else res[[2]]
+           dealWith( .External(CppMethod__invoke, class_pointer, pointer, .pointer, ...) )
         }
            ,
             list(
                 class_pointer = METHOD$class_pointer,
                 pointer = METHOD$pointer,
-                CppMethod__invoke = CppMethod__invoke
+                CppMethod__invoke = CppMethod__invoke, 
+                dealWith = dealWith
                  )
             )
             body(f, where) <- extCall

Modified: pkg/Rcpp/inst/include/Rcpp/Module.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Module.h	2010-11-19 17:37:18 UTC (rev 2467)
+++ pkg/Rcpp/inst/include/Rcpp/Module.h	2010-11-20 11:47:09 UTC (rev 2468)
@@ -334,14 +334,15 @@
 		typename vec_signed_method::iterator it = mets->begin() ;
 		int n = mets->size() ;
 		method_class* m = 0 ;
+		bool ok = false ; 
 		for( int i=0; i<n; i++, ++it ){
 		    if( ( (*it)->valid )( args, nargs) ){
 		        m = (*it)->method ;
+		        ok = true ; 
 		        break ;
 		    }
 		}
-		
-		if( m == 0 ){
+		if( !ok ){
 		    throw std::range_error( "could not find valid method" ) ; 	
 		}
 		if( m->is_void() ){



More information about the Rcpp-commits mailing list