[Rprotobuf-commits] r321 - in pkg: R src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat May 8 13:14:12 CEST 2010
Author: romain
Date: 2010-05-08 13:14:07 +0200 (Sat, 08 May 2010)
New Revision: 321
Removed:
pkg/src/field_count.cpp
Modified:
pkg/R/field_count.R
pkg/src/rprotobuf.h
pkg/src/wrapper_Descriptor.cpp
Log:
move fieldcount.cpp to wrapper_* files
Modified: pkg/R/field_count.R
===================================================================
--- pkg/R/field_count.R 2010-05-08 10:32:14 UTC (rev 320)
+++ pkg/R/field_count.R 2010-05-08 11:14:07 UTC (rev 321)
@@ -2,14 +2,14 @@
standardGeneric( "field_count" )
} )
setMethod( "field_count", "Descriptor", function(object){
- .Call( "field_count__Descriptor", object at pointer, PACKAGE = "RProtoBuf" )
+ .Call( "Descriptor__field_count", object at pointer, PACKAGE = "RProtoBuf" )
} )
setGeneric( "nested_type_count", function(object){
standardGeneric( "nested_type_count" )
} )
setMethod( "nested_type_count", "Descriptor", function(object){
- .Call( "nested_type_count__Descriptor", object at pointer, PACKAGE = "RProtoBuf" )
+ .Call( "Descriptor__nested_type_count", object at pointer, PACKAGE = "RProtoBuf" )
} )
@@ -17,7 +17,7 @@
standardGeneric( "enum_type_count" )
} )
setMethod( "enum_type_count", "Descriptor", function(object){
- .Call( "enum_type_count__Descriptor", object at pointer, PACKAGE = "RProtoBuf" )
+ .Call( "Descriptor__enum_type_count", object at pointer, PACKAGE = "RProtoBuf" )
} )
@@ -34,15 +34,15 @@
}
if( has_index ){
- return( .Call( "Descriptor_getFieldByIndex", object at pointer, as.integer(index)-1L, PACKAGE = "RProtoBuf" ) )
+ return( .Call( "Descriptor__field", object at pointer, as.integer(index)-1L, PACKAGE = "RProtoBuf" ) )
}
if( has_number ){
- return( .Call( "Descriptor_getFieldByNumber", object at pointer, as.integer(number), PACKAGE = "RProtoBuf" ) )
+ return( .Call( "Descriptor__FindFieldByNumber", object at pointer, as.integer(number), PACKAGE = "RProtoBuf" ) )
}
if( has_name ){
- return( .Call( "Descriptor_getFieldByName", object at pointer, as.character(name), PACKAGE = "RProtoBuf" ) )
+ return( .Call( "Descriptor__FindFieldByName", object at pointer, as.character(name), PACKAGE = "RProtoBuf" ) )
}
} )
@@ -59,11 +59,11 @@
}
if( has_index ){
- return( .Call( "Descriptor_getNestedTypeByIndex", object at pointer, as.integer(index)-1L, PACKAGE = "RProtoBuf" ) )
+ return( .Call( "Descriptor__nested_type", object at pointer, as.integer(index)-1L, PACKAGE = "RProtoBuf" ) )
}
if( has_name ){
- return( .Call( "Descriptor_getNestedTypeByName", object at pointer, as.character(name), PACKAGE = "RProtoBuf" ) )
+ return( .Call( "Descriptor__FindNestedTypeByName", object at pointer, as.character(name), PACKAGE = "RProtoBuf" ) )
}
} )
@@ -75,11 +75,11 @@
stop( "need exactly one of `index` or `name`" )
}
if( has_index ){
- return( .Call( "Descriptor_getEnumTypeByIndex", object at pointer, as.integer(index)-1L, PACKAGE = "RProtoBuf" ) )
+ return( .Call( "Descriptor__enum_type", object at pointer, as.integer(index)-1L, PACKAGE = "RProtoBuf" ) )
}
if( has_name ){
- return( .Call( "Descriptor_EnumTypeByName", object at pointer, as.character(name), PACKAGE = "RProtoBuf" ) )
+ return( .Call( "Descriptor__FindEnumTypeByName", object at pointer, as.character(name), PACKAGE = "RProtoBuf" ) )
}
})
Deleted: pkg/src/field_count.cpp
===================================================================
--- pkg/src/field_count.cpp 2010-05-08 10:32:14 UTC (rev 320)
+++ pkg/src/field_count.cpp 2010-05-08 11:14:07 UTC (rev 321)
@@ -1,80 +0,0 @@
-#include "rprotobuf.h"
-
-namespace rprotobuf {
-
- SEXP field_count__Descriptor( SEXP xp ){
- GPB::Descriptor* d = (GPB::Descriptor*)EXTPTR_PTR(xp) ;
- return Rf_ScalarInteger( d->field_count() ) ;
- }
-
- SEXP nested_type_count__Descriptor( SEXP xp ){
- GPB::Descriptor* d = (GPB::Descriptor*)EXTPTR_PTR(xp) ;
- return Rf_ScalarInteger( d->field_count() ) ;
- }
-
- SEXP enum_type_count__Descriptor( SEXP xp ){
- GPB::Descriptor* d = (GPB::Descriptor*)EXTPTR_PTR(xp) ;
- return Rf_ScalarInteger( d->enum_type_count() ) ;
- }
-
- SEXP Descriptor_getFieldByIndex( SEXP xp, SEXP index ){
- GPB::Descriptor* d = (GPB::Descriptor*)EXTPTR_PTR(xp) ;
- int i = INTEGER(index)[0] ;
- const GPB::FieldDescriptor* field_desc = d->field( i ) ;
- if( !field_desc ) return R_NilValue ;
- return new_RS4_FieldDescriptor( field_desc ) ;
- }
-
- SEXP Descriptor_getFieldByNumber( SEXP xp, SEXP number ){
- GPB::Descriptor* d = (GPB::Descriptor*)EXTPTR_PTR(xp) ;
- int num = INTEGER(number)[0] ;
- const GPB::FieldDescriptor* field_desc = d->FindFieldByNumber( num ) ;
- if( !field_desc ) return R_NilValue ;
- return new_RS4_FieldDescriptor( field_desc ) ;
- }
-
- SEXP Descriptor_getFieldByName( SEXP xp, SEXP name ){
- GPB::Descriptor* d = (GPB::Descriptor*)EXTPTR_PTR(xp) ;
- std::string nam = CHAR( STRING_ELT(name, 0) ) ;
- const GPB::FieldDescriptor* field_desc = d->FindFieldByName( nam ) ;
- if( !field_desc ) return R_NilValue ;
- return new_RS4_FieldDescriptor( field_desc ) ;
- }
-
-
- SEXP Descriptor_getNestedTypeByIndex( SEXP xp, SEXP index ){
- GPB::Descriptor* d = (GPB::Descriptor*)EXTPTR_PTR(xp) ;
- int i = INTEGER(index)[0] ;
- const GPB::Descriptor* nested_desc = d->nested_type( i ) ;
- if( !nested_desc ) return R_NilValue ;
- return new_RS4_Descriptor( nested_desc ) ;
- }
-
- SEXP Descriptor_getNestedTypeByName( SEXP xp, SEXP name ){
- GPB::Descriptor* d = (GPB::Descriptor*)EXTPTR_PTR(xp) ;
- std::string nam = CHAR( STRING_ELT(name, 0) ) ;
- const GPB::Descriptor* nested_desc = d->FindNestedTypeByName( nam ) ;
- if( !nested_desc ) return R_NilValue ;
- return new_RS4_Descriptor( nested_desc ) ;
- }
-
-
- SEXP Descriptor_getEnumTypeByIndex( SEXP xp, SEXP index ){
- GPB::Descriptor* d = (GPB::Descriptor*)EXTPTR_PTR(xp) ;
- int i = INTEGER(index)[0] ;
- const GPB::EnumDescriptor* enum_desc = d->enum_type( i ) ;
- if( !enum_desc ) return R_NilValue ;
- return new_RS4_EnumDescriptor( enum_desc ) ;
- }
-
- SEXP Descriptor_getEnumTypeByName( SEXP xp, SEXP name ){
- GPB::Descriptor* d = (GPB::Descriptor*)EXTPTR_PTR(xp) ;
- std::string nam = CHAR( STRING_ELT(name, 0) ) ;
- const GPB::EnumDescriptor* enum_desc = d->FindEnumTypeByName( nam ) ;
- if( !enum_desc ) return R_NilValue ;
- return new_RS4_EnumDescriptor( enum_desc ) ;
- }
-
-
-} // namespace rprotobuf
-
Modified: pkg/src/rprotobuf.h
===================================================================
--- pkg/src/rprotobuf.h 2010-05-08 10:32:14 UTC (rev 320)
+++ pkg/src/rprotobuf.h 2010-05-08 11:14:07 UTC (rev 321)
@@ -338,19 +338,7 @@
RcppExport SEXP name_method_descriptor( SEXP, SEXP ) ;
RcppExport SEXP name_file_descriptor( SEXP ) ;
-/* in field_count.cpp */
-RcppExport SEXP field_count__Descriptor( SEXP );
-RcppExport SEXP nested_type_count__Descriptor( SEXP );
-RcppExport SEXP enum_type_count__Descriptor( SEXP );
-RcppExport SEXP Descriptor_getFieldByIndex( SEXP, SEXP) ;
-RcppExport SEXP Descriptor_getFieldByNumber( SEXP, SEXP ) ;
-RcppExport SEXP Descriptor_getFieldByName(SEXP, SEXP) ;
-RcppExport SEXP Descriptor_getNestedTypeByIndex( SEXP, SEXP) ;
-RcppExport SEXP Descriptor_getNestedTypeByName( SEXP, SEXP);
-RcppExport SEXP Descriptor_getEnumTypeByIndex( SEXP, SEXP);
-RcppExport SEXP Descriptor_getEnumTypeByName( SEXP, SEXP);
-
-/* in ServiceDescriptor_wrapper.cpp */
+/* in wrapper_ServiceDescriptor.cpp */
RcppExport SEXP ServiceDescriptor_length(SEXP);
RcppExport SEXP ServiceDescriptor_method_count(SEXP) ;
RcppExport SEXP ServiceDescriptor_getMethodByIndex(SEXP, SEXP) ;
Modified: pkg/src/wrapper_Descriptor.cpp
===================================================================
--- pkg/src/wrapper_Descriptor.cpp 2010-05-08 10:32:14 UTC (rev 320)
+++ pkg/src/wrapper_Descriptor.cpp 2010-05-08 11:14:07 UTC (rev 321)
@@ -6,8 +6,13 @@
#define METHOD(__NAME__) RCPP_PP_CAT(Descriptor__,__NAME__)
RCPP_XP_METHOD_0( METHOD(as_character), GPB::Descriptor , DebugString)
+RCPP_XP_METHOD_0( METHOD(field_count), GPB::Descriptor, field_count )
+RCPP_XP_METHOD_0( METHOD(nested_type_count), GPB::Descriptor, nested_type_count )
+RCPP_XP_METHOD_0( METHOD(enum_type_count), GPB::Descriptor, enum_type_count )
+
RCPP_XP_METHOD_CAST_0( METHOD(containing_type), GPB::Descriptor, containing_type, RS4_Descriptor )
+
/**
* @param xp external pointer to a Descriptor
* @return the descriptor as an R list
@@ -43,6 +48,35 @@
return message ;
}
+RCPP_FUNCTION_2( S4_FieldDescriptor, METHOD(field), Rcpp::XPtr<GPB::Descriptor> d, int i){
+ return d->field( i ) ;
+}
+
+RCPP_FUNCTION_2( S4_FieldDescriptor, METHOD(FindFieldByNumber), Rcpp::XPtr<GPB::Descriptor> d, int num){
+ return d->FindFieldByNumber( num ) ;
+}
+
+RCPP_FUNCTION_2( S4_FieldDescriptor, METHOD(FindFieldByName), Rcpp::XPtr<GPB::Descriptor> d, std::string nam ){
+ return d->FindFieldByName( nam ) ;
+}
+
+RCPP_FUNCTION_2( S4_Descriptor, METHOD(nested_type), Rcpp::XPtr<GPB::Descriptor> d, int i){
+ return d->nested_type( i ) ;
+}
+
+RCPP_FUNCTION_2( S4_Descriptor, METHOD(FindNestedTypeByName), Rcpp::XPtr<GPB::Descriptor> d, std::string nam){
+ return d->FindNestedTypeByName( nam ) ;
+}
+
+RCPP_FUNCTION_2( S4_EnumDescriptor, METHOD(enum_type), Rcpp::XPtr<GPB::Descriptor> d, int i){
+ return d->enum_type( i ) ;
+}
+
+RCPP_FUNCTION_2( S4_EnumDescriptor, METHOD(enum_type), Rcpp::XPtr<GPB::Descriptor> d, std::string name){
+ return d->FindEnumTypeByName( i ) ;
+}
+
+
#undef METHOD
} // namespace rprotobuf
More information about the Rprotobuf-commits
mailing list