[Rcpp-commits] r2081 - in pkg/Rcpp: inst inst/include/Rcpp src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Sep 8 09:43:44 CEST 2010
Author: romain
Date: 2010-09-08 09:43:44 +0200 (Wed, 08 Sep 2010)
New Revision: 2081
Modified:
pkg/Rcpp/inst/ChangeLog
pkg/Rcpp/inst/include/Rcpp/Module.h
pkg/Rcpp/src/Module.cpp
Log:
accessing the list of declared properties of a C++ class
Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog 2010-09-07 19:50:23 UTC (rev 2080)
+++ pkg/Rcpp/inst/ChangeLog 2010-09-08 07:43:44 UTC (rev 2081)
@@ -1,3 +1,10 @@
+2010-09-10 Romain Francois <romain at r-enthusiasts.com>
+
+ * inst/include/Rcpp/Module.h : added class_Base::property_names method
+ to grab the names of all fields (properties)
+ * src/Module.cpp : added R access (.Call) function CppClass__properties
+ to grab the names of the fields (property) from the XP of a class
+
2010-09-06 Dirk Eddelbuettel <edd at debian.org>
* inst/examples/ConvolveBenchmarks/exampleRCode.r: Rewritten /
Modified: pkg/Rcpp/inst/include/Rcpp/Module.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Module.h 2010-09-07 19:50:23 UTC (rev 2080)
+++ pkg/Rcpp/inst/include/Rcpp/Module.h 2010-09-08 07:43:44 UTC (rev 2081)
@@ -66,6 +66,8 @@
return R_NilValue ;
}
virtual Rcpp::CharacterVector method_names(){ return Rcpp::CharacterVector(0) ; }
+ virtual Rcpp::CharacterVector property_names(){ return Rcpp::CharacterVector(0) ; }
+
virtual Rcpp::CharacterVector complete(){ return Rcpp::CharacterVector(0) ; }
virtual ~class_Base(){}
@@ -230,6 +232,16 @@
return out ;
}
+ Rcpp::CharacterVector property_names(){
+ int n = properties.size() ;
+ Rcpp::CharacterVector out(n) ;
+ typename PROPERTY_MAP::iterator it = properties.begin( ) ;
+ for( int i=0; i<n; i++, ++it){
+ out[i] = it->first ;
+ }
+ return out ;
+ }
+
Rcpp::CharacterVector complete(){
int n = methods.size() - specials ;
int ntotal = n + properties.size() ;
Modified: pkg/Rcpp/src/Module.cpp
===================================================================
--- pkg/Rcpp/src/Module.cpp 2010-09-07 19:50:23 UTC (rev 2080)
+++ pkg/Rcpp/src/Module.cpp 2010-09-08 07:43:44 UTC (rev 2081)
@@ -53,6 +53,9 @@
RCPP_FUNCTION_1( Rcpp::CharacterVector, CppClass__methods, XP_Class cl){
return cl->method_names() ;
}
+RCPP_FUNCTION_1( Rcpp::CharacterVector, CppClass__properties, XP_Class cl){
+ return cl->property_names() ;
+}
RCPP_FUNCTION_1( Rcpp::IntegerVector, Module__funtions_arity, XP_Module module ){
return module-> functions_arity() ;
}
More information about the Rcpp-commits
mailing list