[Rcpp-commits] r2170 - in pkg/Rcpp: . R inst inst/include/Rcpp src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Sep 25 11:17:46 CEST 2010


Author: romain
Date: 2010-09-25 11:17:46 +0200 (Sat, 25 Sep 2010)
New Revision: 2170

Modified:
   pkg/Rcpp/NAMESPACE
   pkg/Rcpp/R/00_classes.R
   pkg/Rcpp/R/Module.R
   pkg/Rcpp/inst/ChangeLog
   pkg/Rcpp/inst/include/Rcpp/routines.h
   pkg/Rcpp/src/Rcpp_init.c
Log:
also register .External routines

Modified: pkg/Rcpp/NAMESPACE
===================================================================
--- pkg/Rcpp/NAMESPACE	2010-09-25 08:51:25 UTC (rev 2169)
+++ pkg/Rcpp/NAMESPACE	2010-09-25 09:17:46 UTC (rev 2170)
@@ -1,4 +1,5 @@
 useDynLib(Rcpp, 
+    # .Call functions
     as_character_externalptr,
     
     CppField__get, CppField__set,
@@ -9,7 +10,10 @@
     
     Module__classes_info,Module__complete,Module__get_class,
     Module__has_class,Module__has_function,Module__functions_arity,
-    Module__name
+    Module__name, 
+    
+    # .External functions
+    CppMethod__invoke, InternalFunction_invoke, Module__invoke, class__newInstance
 )
 
 import( methods )

Modified: pkg/Rcpp/R/00_classes.R
===================================================================
--- pkg/Rcpp/R/00_classes.R	2010-09-25 08:51:25 UTC (rev 2169)
+++ pkg/Rcpp/R/00_classes.R	2010-09-25 09:17:46 UTC (rev 2170)
@@ -49,7 +49,7 @@
     ), 
     methods = list( 
         invoke = function(obj_xp, ...){
-            .External( "CppMethod__invoke", class_pointer, pointer, obj_xp, ..., PACKAGE = "Rcpp" )    
+            .External( CppMethod__invoke, class_pointer, pointer, obj_xp, ... )    
         }
     )
 )

Modified: pkg/Rcpp/R/Module.R
===================================================================
--- pkg/Rcpp/R/Module.R	2010-09-25 08:51:25 UTC (rev 2169)
+++ pkg/Rcpp/R/Module.R	2010-09-25 09:17:46 UTC (rev 2170)
@@ -19,7 +19,7 @@
 	f <- function(xp){
 		force(xp)
 		function(...){
-			.External( "InternalFunction_invoke" , PACKAGE = "Rcpp", xp, ... )
+			.External( InternalFunction_invoke, xp, ... )
 		}
 	}
 	o <- new( "C++Function", f(pointer) )
@@ -72,7 +72,7 @@
     pointer <- .getModulePointer(x)
 	if( .Call( Module__has_function, pointer, name ) ){
 		function( ... ) {
-			res <- .External(  "Module__invoke" , pointer, name, ..., PACKAGE = "Rcpp"  )
+			res <- .External( Module__invoke , pointer, name, ... )
 			if( isTRUE( res$void ) ) invisible(NULL) else res$result
 		}
 	} else if( .Call( Module__has_class, pointer, name ) ){
@@ -85,7 +85,7 @@
 } )
 
 new_CppObject_xp <- function(module, pointer, ...) {
-	.External( "class__newInstance", module, pointer, ..., PACKAGE = "Rcpp" )
+	.External( class__newInstance, module, pointer, ... )
 }
 
 

Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog	2010-09-25 08:51:25 UTC (rev 2169)
+++ pkg/Rcpp/inst/ChangeLog	2010-09-25 09:17:46 UTC (rev 2170)
@@ -4,7 +4,8 @@
     
     * src/Rcpp_init.c: register routines
     
-    * R/*.R: use registration information in many .Call to speed things up
+    * R/*.R: use registration information in many .Call and .External functions
+    to speed things up
 
 2010-09-24  Romain Francois <romain at r-enthusiasts.com>
 

Modified: pkg/Rcpp/inst/include/Rcpp/routines.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/routines.h	2010-09-25 08:51:25 UTC (rev 2169)
+++ pkg/Rcpp/inst/include/Rcpp/routines.h	2010-09-25 09:17:46 UTC (rev 2170)
@@ -28,6 +28,7 @@
 #define CALLFUN_3(name) SEXP name(SEXP,SEXP,SEXP)
 #define CALLFUN_4(name) SEXP name(SEXP,SEXP,SEXP,SEXP)
 #define CALLFUN_5(name) SEXP name(SEXP,SEXP,SEXP,SEXP,SEXP)
+#define EXTFUN(name) SEXP name(SEXP)
 
 // we have to do the ifdef __cplusplus dance because this file
 // is included both in C and C++ files
@@ -51,6 +52,12 @@
 CALLFUN_2(Module__has_function);
 CALLFUN_1(Module__name);
 
+/* .External functions */
+EXTFUN(CppMethod__invoke) ;
+EXTFUN(InternalFunction_invoke) ;
+EXTFUN(Module__invoke) ;
+EXTFUN(class__newInstance) ;
+
 #ifdef __cplusplus
 }
 #endif

Modified: pkg/Rcpp/src/Rcpp_init.c
===================================================================
--- pkg/Rcpp/src/Rcpp_init.c	2010-09-25 08:51:25 UTC (rev 2169)
+++ pkg/Rcpp/src/Rcpp_init.c	2010-09-25 09:17:46 UTC (rev 2170)
@@ -27,7 +27,9 @@
 
 // borrowed from Matrix
 #define CALLDEF(name, n)  {#name, (DL_FUNC) &name, n}
+#define EXTDEF(name)  {#name, (DL_FUNC) &name, -1}
 
+
 // TODO: check that having this static does not mess up with 
 //       RInside, and move it within init_Rcpp_routines otherwise
 static R_CallMethodDef callEntries[]  = {
@@ -52,6 +54,15 @@
     {NULL, NULL, 0}
 }; 
 
+static R_ExternalMethodDef extEntries[]  = {
+    EXTDEF(CppMethod__invoke),
+    EXTDEF(InternalFunction_invoke),
+    EXTDEF(Module__invoke), 
+    EXTDEF(class__newInstance), 
+    
+    {NULL, NULL, 0}
+} ;
+
 // this is called by R_init_Rcpp that is in Module.cpp
 void init_Rcpp_routines(DllInfo *info){
   /* Register routines, allocate resources. */
@@ -59,7 +70,7 @@
       NULL /* .C*/, 
       callEntries /*.Call*/,
       NULL /* .Fortran */,
-      NULL /*.Extern*/
+      extEntries /*.External*/
   );
 }
           



More information about the Rcpp-commits mailing list