[Rprotobuf-commits] r618 - pkg/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Dec 28 00:42:11 CET 2013
Author: murray
Date: 2013-12-28 00:42:11 +0100 (Sat, 28 Dec 2013)
New Revision: 618
Modified:
pkg/src/wrapper_FieldDescriptor.cpp
pkg/src/wrapper_FileDescriptor.cpp
Log:
Consistent spacing & indentations from clang-format.
Modified: pkg/src/wrapper_FieldDescriptor.cpp
===================================================================
--- pkg/src/wrapper_FieldDescriptor.cpp 2013-12-27 23:39:37 UTC (rev 617)
+++ pkg/src/wrapper_FieldDescriptor.cpp 2013-12-27 23:42:11 UTC (rev 618)
@@ -25,86 +25,90 @@
namespace rprotobuf {
#undef METHOD
-#define METHOD(__NAME__) RCPP_PP_CAT(FieldDescriptor__,__NAME__)
+#define METHOD(__NAME__) RCPP_PP_CAT(FieldDescriptor__, __NAME__)
- RPB_XP_METHOD_0( METHOD(as_character) , GPB::FieldDescriptor, DebugString)
- RPB_XP_METHOD_0( METHOD(is_extension) , GPB::FieldDescriptor, is_extension)
- RPB_XP_METHOD_0( METHOD(number) , GPB::FieldDescriptor, number)
- RPB_XP_METHOD_0( METHOD(type) , GPB::FieldDescriptor, type )
- RPB_XP_METHOD_0( METHOD(cpp_type) , GPB::FieldDescriptor, cpp_type )
- RPB_XP_METHOD_0( METHOD(label) , GPB::FieldDescriptor, label )
- RPB_XP_METHOD_0( METHOD(is_repeated) , GPB::FieldDescriptor, is_repeated )
- RPB_XP_METHOD_0( METHOD(is_optional) , GPB::FieldDescriptor, is_optional )
- RPB_XP_METHOD_0( METHOD(is_required) , GPB::FieldDescriptor, is_required )
- RPB_XP_METHOD_0( METHOD(has_default_value) , GPB::FieldDescriptor, has_default_value )
+RPB_XP_METHOD_0(METHOD(as_character), GPB::FieldDescriptor, DebugString)
+RPB_XP_METHOD_0(METHOD(is_extension), GPB::FieldDescriptor, is_extension)
+RPB_XP_METHOD_0(METHOD(number), GPB::FieldDescriptor, number)
+RPB_XP_METHOD_0(METHOD(type), GPB::FieldDescriptor, type)
+RPB_XP_METHOD_0(METHOD(cpp_type), GPB::FieldDescriptor, cpp_type)
+RPB_XP_METHOD_0(METHOD(label), GPB::FieldDescriptor, label)
+RPB_XP_METHOD_0(METHOD(is_repeated), GPB::FieldDescriptor, is_repeated)
+RPB_XP_METHOD_0(METHOD(is_optional), GPB::FieldDescriptor, is_optional)
+RPB_XP_METHOD_0(METHOD(is_required), GPB::FieldDescriptor, is_required)
+RPB_XP_METHOD_0(METHOD(has_default_value), GPB::FieldDescriptor,
+ has_default_value)
- RPB_FUNCTION_1( S4_Descriptor, METHOD(containing_type), Rcpp::XPtr<GPB::FieldDescriptor> d){
- return S4_Descriptor( d->containing_type() ) ;
- }
-
-#define RPB_HANDLE_CASE(__CPP__,__LC__) \
-case CPPTYPE_##__CPP__: \
- { \
- return Rcpp::wrap( d->default_value_##__LC__() ); \
- break ; \
- }
+RPB_FUNCTION_1(S4_Descriptor, METHOD(containing_type),
+ Rcpp::XPtr<GPB::FieldDescriptor> d) {
+ return S4_Descriptor(d->containing_type());
+}
- RPB_FUNCTION_1( SEXP, METHOD(default_value) , Rcpp::XPtr<GPB::FieldDescriptor> d ){
- switch( d->cpp_type() ){
-
- RPB_HANDLE_CASE(INT32,int32)
- RPB_HANDLE_CASE(UINT32,uint32)
+#define RPB_HANDLE_CASE(__CPP__, __LC__) \
+ case CPPTYPE_##__CPP__: { \
+ return Rcpp::wrap(d->default_value_##__LC__()); \
+ break; \
+ }
+
+RPB_FUNCTION_1(SEXP, METHOD(default_value),
+ Rcpp::XPtr<GPB::FieldDescriptor> d) {
+ switch (d->cpp_type()) {
+
+ RPB_HANDLE_CASE(INT32, int32)
+ RPB_HANDLE_CASE(UINT32, uint32)
#ifdef RCPP_HAS_LONG_LONG_TYPES
- RPB_HANDLE_CASE(INT64,int64)
- RPB_HANDLE_CASE(UINT64,uint64)
+ RPB_HANDLE_CASE(INT64, int64)
+ RPB_HANDLE_CASE(UINT64, uint64)
#endif
- RPB_HANDLE_CASE(DOUBLE,double)
- RPB_HANDLE_CASE(FLOAT,float)
- RPB_HANDLE_CASE(BOOL,bool)
- RPB_HANDLE_CASE(STRING,string)
+ RPB_HANDLE_CASE(DOUBLE, double)
+ RPB_HANDLE_CASE(FLOAT, float)
+ RPB_HANDLE_CASE(BOOL, bool)
+ RPB_HANDLE_CASE(STRING, string)
- case CPPTYPE_ENUM:
- {
- return Rf_ScalarInteger( d->default_value_enum()->number() ) ;
- break ;
- }
- default:
- break ;
- }
- return R_NilValue ;
- }
-
- RPB_FUNCTION_1(S4_Descriptor, METHOD(message_type), Rcpp::XPtr<GPB::FieldDescriptor> d){
- if( d->cpp_type() != CPPTYPE_MESSAGE ){
- throw Rcpp::not_compatible( "not a message type field" ) ;
- }
- return S4_Descriptor( d->message_type() ) ;
- }
-
- RPB_FUNCTION_1(S4_EnumDescriptor, METHOD(enum_type), Rcpp::XPtr<GPB::FieldDescriptor> d){
- if( d->cpp_type() != CPPTYPE_ENUM ){
- Rcpp::stop("not an enum type field");
- }
- return S4_EnumDescriptor( d->enum_type() ) ;
- }
+ case CPPTYPE_ENUM: {
+ return Rf_ScalarInteger(d->default_value_enum()->number());
+ break;
+ }
+ default:
+ break;
+ }
+ return R_NilValue;
+}
- RPB_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::FieldDescriptor> d ){
- GPB::FieldDescriptorProto* message = new GPB::FieldDescriptorProto() ;
- d->CopyTo( message );
- return S4_Message( message ) ;
- }
-
- RPB_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::FieldDescriptor> desc){
- return S4_FileDescriptor( desc->file() );
- }
+RPB_FUNCTION_1(S4_Descriptor, METHOD(message_type),
+ Rcpp::XPtr<GPB::FieldDescriptor> d) {
+ if (d->cpp_type() != CPPTYPE_MESSAGE) {
+ throw Rcpp::not_compatible("not a message type field");
+ }
+ return S4_Descriptor(d->message_type());
+}
- RPB_FUNCTION_2( std::string, METHOD(name), Rcpp::XPtr<GPB::FieldDescriptor> d, bool full){
- return full ? d->full_name() : d->name() ;
- }
-
-
+RPB_FUNCTION_1(S4_EnumDescriptor, METHOD(enum_type),
+ Rcpp::XPtr<GPB::FieldDescriptor> d) {
+ if (d->cpp_type() != CPPTYPE_ENUM) {
+ Rcpp::stop("not an enum type field");
+ }
+ return S4_EnumDescriptor(d->enum_type());
+}
+
+RPB_FUNCTION_1(S4_Message, METHOD(as_Message),
+ Rcpp::XPtr<GPB::FieldDescriptor> d) {
+ GPB::FieldDescriptorProto* message = new GPB::FieldDescriptorProto();
+ d->CopyTo(message);
+ return S4_Message(message);
+}
+
+RPB_FUNCTION_1(S4_FileDescriptor, METHOD(fileDescriptor),
+ Rcpp::XPtr<GPB::FieldDescriptor> desc) {
+ return S4_FileDescriptor(desc->file());
+}
+
+RPB_FUNCTION_2(std::string, METHOD(name), Rcpp::XPtr<GPB::FieldDescriptor> d,
+ bool full) {
+ return full ? d->full_name() : d->name();
+}
+
#undef RPB_HANDLE_CASE
#undef METHOD
-
-} // namespace rprotobuf
+} // namespace rprotobuf
Modified: pkg/src/wrapper_FileDescriptor.cpp
===================================================================
--- pkg/src/wrapper_FileDescriptor.cpp 2013-12-27 23:39:37 UTC (rev 617)
+++ pkg/src/wrapper_FileDescriptor.cpp 2013-12-27 23:42:11 UTC (rev 618)
@@ -1,96 +1,98 @@
#include "rprotobuf.h"
#include "RcppMacros.h"
-namespace rprotobuf{
+namespace rprotobuf {
#undef METHOD
-#define METHOD(__NAME__) RCPP_PP_CAT(FileDescriptor__,__NAME__)
+#define METHOD(__NAME__) RCPP_PP_CAT(FileDescriptor__, __NAME__)
-RPB_XP_METHOD_0( METHOD(as_character) , GPB::FileDescriptor , DebugString) ;
+RPB_XP_METHOD_0(METHOD(as_character), GPB::FileDescriptor, DebugString);
-RPB_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::FileDescriptor> d ){
- GPB::FileDescriptorProto* message = new GPB::FileDescriptorProto() ;
- d->CopyTo( message );
- return S4_Message( message ) ;
+RPB_FUNCTION_1(S4_Message, METHOD(as_Message),
+ Rcpp::XPtr<GPB::FileDescriptor> d) {
+ GPB::FileDescriptorProto* message = new GPB::FileDescriptorProto();
+ d->CopyTo(message);
+ return S4_Message(message);
}
+RPB_FUNCTION_1(Rcpp::CharacterVector, METHOD(getMemberNames),
+ Rcpp::XPtr<GPB::FileDescriptor> desc) {
+ int ntypes = desc->message_type_count();
+ int nenums = desc->enum_type_count();
+ int nserv = desc->service_count();
+ int nexts = desc->extension_count();
-RPB_FUNCTION_1( Rcpp::CharacterVector, METHOD(getMemberNames), Rcpp::XPtr<GPB::FileDescriptor> desc ){
- int ntypes = desc->message_type_count() ;
- int nenums = desc->enum_type_count() ;
- int nserv = desc->service_count() ;
- int nexts = desc->extension_count() ;
-
- Rcpp::CharacterVector res( ntypes + nenums + nserv + nexts ) ;
- int i=0;
- int j=0;
- while( i<ntypes){
- res[j] = desc->message_type(i)->name() ;
- i++;
- j++;
- }
- i=0;
- while( i<nenums){
- res[j] = desc->enum_type(i)->name() ;
- i++;
- j++;
- }
- i = 0;
- while( i<nserv){
- res[j] = desc->service(i)->name() ;
- i++;
- j++;
- }
- i = 0;
- while( i<nexts){
- res[j] = desc->extension(i)->name() ;
- i++;
- j++;
- }
- return res ;
-
+ Rcpp::CharacterVector res(ntypes + nenums + nserv + nexts);
+ int i = 0;
+ int j = 0;
+ while (i < ntypes) {
+ res[j] = desc->message_type(i)->name();
+ i++;
+ j++;
+ }
+ i = 0;
+ while (i < nenums) {
+ res[j] = desc->enum_type(i)->name();
+ i++;
+ j++;
+ }
+ i = 0;
+ while (i < nserv) {
+ res[j] = desc->service(i)->name();
+ i++;
+ j++;
+ }
+ i = 0;
+ while (i < nexts) {
+ res[j] = desc->extension(i)->name();
+ i++;
+ j++;
+ }
+ return res;
}
/**
* @param xp (GPB::FileDescriptor*) external pointer
* @return the descriptor as an R list
*/
-RPB_FUNCTION_1( Rcpp::List, METHOD(as_list), Rcpp::XPtr<GPB::FileDescriptor> desc ){
- int ntypes = desc->message_type_count() ;
- int nenums = desc->enum_type_count() ;
- int nserv = desc->service_count() ;
- int nexts = desc->extension_count() ;
- int n = ntypes + nenums + nserv + nexts;
-
- Rcpp::CharacterVector names(n) ;
- 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) ) ;
- names[j] = desc->message_type(i)->name() ;
- }
- for( i=0; i<nenums; j++, i++){
- res[j] = S4_EnumDescriptor( desc->enum_type(i) );
- names[j] = desc->enum_type(i)->name() ;
- }
- for( i=0; i<nserv; j++, i++){
- res[j] = S4_ServiceDescriptor( desc->service(i) );
- names[j] = desc->service(i)->name() ;
- }
- for( i=0; i<nexts; j++, i++){
- res[j] = S4_FieldDescriptor( desc->extension(i) );
- // always use full names for extensions
- names[j] = desc->extension(i)->full_name() ;
- }
- res.names() = names ;
- return res;
+RPB_FUNCTION_1(Rcpp::List, METHOD(as_list),
+ Rcpp::XPtr<GPB::FileDescriptor> desc) {
+ int ntypes = desc->message_type_count();
+ int nenums = desc->enum_type_count();
+ int nserv = desc->service_count();
+ int nexts = desc->extension_count();
+ int n = ntypes + nenums + nserv + nexts;
+
+ Rcpp::CharacterVector names(n);
+ 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));
+ names[j] = desc->message_type(i)->name();
+ }
+ for (i = 0; i < nenums; j++, i++) {
+ res[j] = S4_EnumDescriptor(desc->enum_type(i));
+ names[j] = desc->enum_type(i)->name();
+ }
+ for (i = 0; i < nserv; j++, i++) {
+ res[j] = S4_ServiceDescriptor(desc->service(i));
+ names[j] = desc->service(i)->name();
+ }
+ for (i = 0; i < nexts; j++, i++) {
+ res[j] = S4_FieldDescriptor(desc->extension(i));
+ // always use full names for extensions
+ names[j] = desc->extension(i)->full_name();
+ }
+ res.names() = names;
+ return res;
}
-RPB_FUNCTION_1( std::string, METHOD(name), Rcpp::XPtr<GPB::FileDescriptor> desc ){
- return desc->name() ;
+RPB_FUNCTION_1(std::string, METHOD(name),
+ Rcpp::XPtr<GPB::FileDescriptor> desc) {
+ return desc->name();
}
#undef METHOD
-} // namespace rprotobuf
+} // namespace rprotobuf
More information about the Rprotobuf-commits
mailing list