[Rprotobuf-commits] r317 - in pkg: R src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat May 8 12:20:28 CEST 2010
Author: romain
Date: 2010-05-08 12:20:27 +0200 (Sat, 08 May 2010)
New Revision: 317
Modified:
pkg/R/aslist.R
pkg/src/aslist.cpp
pkg/src/rprotobuf.h
pkg/src/wrapper_EnumDescriptor.cpp
pkg/src/wrapper_FileDescriptor.cpp
Log:
moving aslist.cpp to wrapper_*
Modified: pkg/R/aslist.R
===================================================================
--- pkg/R/aslist.R 2010-05-08 10:14:19 UTC (rev 316)
+++ pkg/R/aslist.R 2010-05-08 10:20:27 UTC (rev 317)
@@ -2,13 +2,13 @@
.Call( "Message__as_list", x at pointer, PACKAGE = "RProtoBuf" )
}
as.list.Descriptor <- function(x, ...){
- .Call( "as_list_descriptor", x at pointer, PACKAGE = "RProtoBuf" )
+ .Call( "Descriptor__as_list", x at pointer, PACKAGE = "RProtoBuf" )
}
as.list.EnumDescriptor <- function( x, ...){
- .Call( "as_list_enum_descriptor", x at pointer, PACKAGE = "RProtoBuf" )
+ .Call( "EnumDescriptor__as_list", x at pointer, PACKAGE = "RProtoBuf" )
}
as.list.FileDescriptor <- function( x, ...){
- .Call( "as_list_file_descriptor", x at pointer, PACKAGE = "RProtoBuf" )
+ .Call( "FileDescriptor__as_list", x at pointer, PACKAGE = "RProtoBuf" )
}
as.list.ServiceDescriptor <- function( x, ...){
.Call( "ServiceDescriptor__as_list", x at pointer, PACKAGE = "RProtoBuf" )
Modified: pkg/src/aslist.cpp
===================================================================
--- pkg/src/aslist.cpp 2010-05-08 10:14:19 UTC (rev 316)
+++ pkg/src/aslist.cpp 2010-05-08 10:20:27 UTC (rev 317)
@@ -2,62 +2,7 @@
namespace rprotobuf{
-/**
- * @param xp external pointer to a Descriptor
- * @return the descriptor as an R list
- */
-RCPP_FUNCTION_1( Rcpp::IntegerVector, as_list_enum_descriptor, Rcpp::XPtr<GPB::EnumDescriptor> d ){
-
- int n = d->value_count() ;
- Rcpp::IntegerVector values(n) ;
- Rcpp::CharacterVector names(n) ;
-
- for( int i=0; i<n; i++){
- const GPB::EnumValueDescriptor* value_d = d->value(i) ;
- values[i] = value_d->number() ;
- names[i] = value_d->name() ;
- }
- values.names() = names ;
- return values;
-}
-/**
- * @param xp (GPB::FileDescriptor*) external pointer
- * @return the descriptor as an R list
- */
-RCPP_FUNCTION_1( Rcpp::List, as_list_file_descriptor, Rcpp::XPtr<GPB::FileDescriptor> desc ){
-
-#ifdef RPB_DEBUG
-Rprintf( "<as_list_file_descriptor>\n" ) ;
-#endif
-
- Rcpp::CharacterVector names = getFileDescriptorMemberNames(desc) ;
- int n = names.size() ;
- int ntypes = desc->message_type_count() ;
- int nenums = desc->enum_type_count() ;
- int nserv = desc->service_count() ;
-
- Rcpp::List res( n );
- int i=0;
- int j=0;
- for( i=0; i<ntypes; j++, i++){
- res[j] = S4_Descriptor( desc->message_type(i) ) ;
- }
- for( i=0; i<nenums; j++, i++){
- res[j] = S4_EnumDescriptor( desc->enum_type(i) );
- }
- for( i=0; i<nserv; j++, i++){
- res[j] = S4_ServiceDescriptor( desc->service(i) );
- }
- res.names() = names ;
-
-#ifdef RPB_DEBUG
-Rprintf( "</as_list_file_descriptor>\n" ) ;
-#endif
- return res;
-}
-
-
} // namespace rprotobuf
Modified: pkg/src/rprotobuf.h
===================================================================
--- pkg/src/rprotobuf.h 2010-05-08 10:14:19 UTC (rev 316)
+++ pkg/src/rprotobuf.h 2010-05-08 10:20:27 UTC (rev 317)
@@ -300,11 +300,6 @@
RcppExport void CHECK_values_for_enum( GPB::FieldDescriptor*, SEXP) ;
RcppExport void CHECK_messages( GPB::FieldDescriptor*, SEXP) ;
-/* in aslist.cpp */
-RcppExport SEXP as_list_descriptor( SEXP );
-RcppExport SEXP as_list_enum_descriptor( SEXP );
-RcppExport SEXP as_list_file_descriptor( SEXP ) ;
-
/* in merge.cpp */
RcppExport SEXP merge_message( SEXP, SEXP );
Modified: pkg/src/wrapper_EnumDescriptor.cpp
===================================================================
--- pkg/src/wrapper_EnumDescriptor.cpp 2010-05-08 10:14:19 UTC (rev 316)
+++ pkg/src/wrapper_EnumDescriptor.cpp 2010-05-08 10:20:27 UTC (rev 317)
@@ -38,6 +38,24 @@
return evd->number();
}
+/**
+ * @param xp external pointer to a Descriptor
+ * @return the descriptor as an R list
+ */
+RCPP_FUNCTION_1( Rcpp::IntegerVector, METHOD(as_list), Rcpp::XPtr<GPB::EnumDescriptor> d ){
+
+ int n = d->value_count() ;
+ Rcpp::IntegerVector values(n) ;
+ Rcpp::CharacterVector names(n) ;
+
+ for( int i=0; i<n; i++){
+ const GPB::EnumValueDescriptor* value_d = d->value(i) ;
+ values[i] = value_d->number() ;
+ names[i] = value_d->name() ;
+ }
+ values.names() = names ;
+ return values;
+}
#undef METHOD
Modified: pkg/src/wrapper_FileDescriptor.cpp
===================================================================
--- pkg/src/wrapper_FileDescriptor.cpp 2010-05-08 10:14:19 UTC (rev 316)
+++ pkg/src/wrapper_FileDescriptor.cpp 2010-05-08 10:20:27 UTC (rev 317)
@@ -12,7 +12,43 @@
d->CopyTo( message );
return message ;
}
+
+/**
+ * @param xp (GPB::FileDescriptor*) external pointer
+ * @return the descriptor as an R list
+ */
+RCPP_FUNCTION_1( Rcpp::List, METHOD(as_list), Rcpp::XPtr<GPB::FileDescriptor> desc ){
+
+#ifdef RPB_DEBUG
+Rprintf( "<as_list_file_descriptor>\n" ) ;
+#endif
+ Rcpp::CharacterVector names = getFileDescriptorMemberNames(desc) ;
+ int n = names.size() ;
+ int ntypes = desc->message_type_count() ;
+ int nenums = desc->enum_type_count() ;
+ int nserv = desc->service_count() ;
+
+ Rcpp::List res( n );
+ int i=0;
+ int j=0;
+ for( i=0; i<ntypes; j++, i++){
+ res[j] = S4_Descriptor( desc->message_type(i) ) ;
+ }
+ for( i=0; i<nenums; j++, i++){
+ res[j] = S4_EnumDescriptor( desc->enum_type(i) );
+ }
+ for( i=0; i<nserv; j++, i++){
+ res[j] = S4_ServiceDescriptor( desc->service(i) );
+ }
+ res.names() = names ;
+
+#ifdef RPB_DEBUG
+Rprintf( "</as_list_file_descriptor>\n" ) ;
+#endif
+ return res;
+}
+
#undef METHOD
} // namespace rprotobuf
More information about the Rprotobuf-commits
mailing list