[Rprotobuf-commits] r619 - pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Dec 28 00:44:50 CET 2013


Author: murray
Date: 2013-12-28 00:44:50 +0100 (Sat, 28 Dec 2013)
New Revision: 619

Modified:
   pkg/src/wrapper_Descriptor.cpp
   pkg/src/wrapper_EnumDescriptor.cpp
Log:
whitespace change only, clang-format consistency.



Modified: pkg/src/wrapper_Descriptor.cpp
===================================================================
--- pkg/src/wrapper_Descriptor.cpp	2013-12-27 23:42:11 UTC (rev 618)
+++ pkg/src/wrapper_Descriptor.cpp	2013-12-27 23:44:50 UTC (rev 619)
@@ -1,19 +1,19 @@
 #include "rprotobuf.h"
 #include "RcppMacros.h"
 
-namespace rprotobuf{
+namespace rprotobuf {
 
 #undef METHOD
-#define METHOD(__NAME__) RCPP_PP_CAT(Descriptor__,__NAME__)	
+#define METHOD(__NAME__) RCPP_PP_CAT(Descriptor__, __NAME__)
 
-RPB_XP_METHOD_0( METHOD(as_character), GPB::Descriptor          , DebugString)
-RPB_XP_METHOD_0( METHOD(field_count), GPB::Descriptor, field_count )
-RPB_XP_METHOD_0( METHOD(nested_type_count), GPB::Descriptor, nested_type_count )
-RPB_XP_METHOD_0( METHOD(enum_type_count), GPB::Descriptor, enum_type_count )
+RPB_XP_METHOD_0(METHOD(as_character), GPB::Descriptor, DebugString)
+RPB_XP_METHOD_0(METHOD(field_count), GPB::Descriptor, field_count)
+RPB_XP_METHOD_0(METHOD(nested_type_count), GPB::Descriptor, nested_type_count)
+RPB_XP_METHOD_0(METHOD(enum_type_count), GPB::Descriptor, enum_type_count)
 
-RPB_XP_METHOD_CAST_0( METHOD(containing_type), GPB::Descriptor, containing_type, S4_Descriptor )
+RPB_XP_METHOD_CAST_0(METHOD(containing_type), GPB::Descriptor, containing_type,
+                     S4_Descriptor)
 
-
 /**
  * returns the names of the members contained in the descriptor
  * (nested types, enums, fields)
@@ -22,177 +22,197 @@
  *
  * @return member names, as an R character vector (STRSXP)
  */
-RPB_FUNCTION_1( Rcpp::CharacterVector, METHOD(getMemberNames), Rcpp::XPtr<GPB::Descriptor> desc ){
-	
-	int nfields = desc->field_count() ;
-	int ntypes  = desc->nested_type_count() ;
-	int nenums  = desc->enum_type_count() ;
-	
-	Rcpp::CharacterVector res(nfields + ntypes + nenums ) ;
-	int j=0; 
-	for (int i=0; i<nfields; i++, j++){
-		res[j] = desc->field(i)->name() ;
-	}
-	for (int i=0;i<ntypes; i++, j++){
-		res[j] = desc->nested_type(i)->name() ;
-	}
-	for (int i=0; i<nenums; i++, j++){
-		res[j] = desc->enum_type(i)->name();
-	}
-	return( res );
+RPB_FUNCTION_1(Rcpp::CharacterVector, METHOD(getMemberNames),
+               Rcpp::XPtr<GPB::Descriptor> desc) {
+
+    int nfields = desc->field_count();
+    int ntypes = desc->nested_type_count();
+    int nenums = desc->enum_type_count();
+
+    Rcpp::CharacterVector res(nfields + ntypes + nenums);
+    int j = 0;
+    for (int i = 0; i < nfields; i++, j++) {
+        res[j] = desc->field(i)->name();
+    }
+    for (int i = 0; i < ntypes; i++, j++) {
+        res[j] = desc->nested_type(i)->name();
+    }
+    for (int i = 0; i < nenums; i++, j++) {
+        res[j] = desc->enum_type(i)->name();
+    }
+    return (res);
 }
 
 /**
  * @param xp external pointer to a Descriptor
  * @return the descriptor as an R list
  */
-RPB_FUNCTION_1( Rcpp::List, METHOD(as_list), Rcpp::XPtr<GPB::Descriptor> desc ){
-	
-	int nfields = desc->field_count() ;
-	int ntypes  = desc->nested_type_count() ;
-	int nenums  = desc->enum_type_count() ;
-	int n       = nfields + ntypes + nenums ;
-	
- 	Rcpp::CharacterVector names(n) ; 
-	Rcpp::List res(n); 
-	int i=0;
-	int j=0; 
-	for( i=0; i<nfields; j++, i++){
-		const GPB::FieldDescriptor* fd = desc->field(i) ;
-		res[j] = S4_FieldDescriptor( fd );
-		names[j] = fd->name() ; 
-	}
-	for( i=0; i<ntypes; j++, i++){
-		const GPB::Descriptor* d  = desc->nested_type(i) ;
-		res[j] = S4_Descriptor( d );
-		names[j] = d->name() ;
-	}
-	for( i=0; i<nenums; j++, i++){
-		const GPB::EnumDescriptor* ed = desc->enum_type(i) ;
-		res[j] = S4_EnumDescriptor( ed );
-		names[j] = ed->name() ;
-	}
-	res.names() = names ;
-	
-	return res; 
+RPB_FUNCTION_1(Rcpp::List, METHOD(as_list), Rcpp::XPtr<GPB::Descriptor> desc) {
+
+    int nfields = desc->field_count();
+    int ntypes = desc->nested_type_count();
+    int nenums = desc->enum_type_count();
+    int n = nfields + ntypes + nenums;
+
+    Rcpp::CharacterVector names(n);
+    Rcpp::List res(n);
+    int i = 0;
+    int j = 0;
+    for (i = 0; i < nfields; j++, i++) {
+        const GPB::FieldDescriptor* fd = desc->field(i);
+        res[j] = S4_FieldDescriptor(fd);
+        names[j] = fd->name();
+    }
+    for (i = 0; i < ntypes; j++, i++) {
+        const GPB::Descriptor* d = desc->nested_type(i);
+        res[j] = S4_Descriptor(d);
+        names[j] = d->name();
+    }
+    for (i = 0; i < nenums; j++, i++) {
+        const GPB::EnumDescriptor* ed = desc->enum_type(i);
+        res[j] = S4_EnumDescriptor(ed);
+        names[j] = ed->name();
+    }
+    res.names() = names;
+
+    return res;
 }
 
-RPB_FUNCTION_1(S4_Message, METHOD(as_Message) , Rcpp::XPtr<GPB::Descriptor> d ){
-	GPB::DescriptorProto* message = new GPB::DescriptorProto() ; 
-	d->CopyTo( message ); 
-	return message  ;
+RPB_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::Descriptor> d) {
+    GPB::DescriptorProto* message = new GPB::DescriptorProto();
+    d->CopyTo(message);
+    return message;
 }
 
-RPB_FUNCTION_2( S4_FieldDescriptor, METHOD(field), Rcpp::XPtr<GPB::Descriptor> d, int i){
-	return d->field( i ) ;
+RPB_FUNCTION_2(S4_FieldDescriptor, METHOD(field), Rcpp::XPtr<GPB::Descriptor> d,
+               int i) {
+    return d->field(i);
 }
 
-RPB_FUNCTION_2( S4_FieldDescriptor, METHOD(FindFieldByNumber), Rcpp::XPtr<GPB::Descriptor> d, int num){
-	return d->FindFieldByNumber( num ) ;
+RPB_FUNCTION_2(S4_FieldDescriptor, METHOD(FindFieldByNumber),
+               Rcpp::XPtr<GPB::Descriptor> d, int num) {
+    return d->FindFieldByNumber(num);
 }
 
-RPB_FUNCTION_2( S4_FieldDescriptor, METHOD(FindFieldByName), Rcpp::XPtr<GPB::Descriptor> d, std::string nam ){
-	return d->FindFieldByName( nam ) ;
+RPB_FUNCTION_2(S4_FieldDescriptor, METHOD(FindFieldByName),
+               Rcpp::XPtr<GPB::Descriptor> d, std::string nam) {
+    return d->FindFieldByName(nam);
 }
 
-RPB_FUNCTION_2( S4_Descriptor, METHOD(nested_type), Rcpp::XPtr<GPB::Descriptor> d, int i){
-	return d->nested_type( i ) ;
+RPB_FUNCTION_2(S4_Descriptor, METHOD(nested_type),
+               Rcpp::XPtr<GPB::Descriptor> d, int i) {
+    return d->nested_type(i);
 }
 
-RPB_FUNCTION_2( S4_Descriptor, METHOD(FindNestedTypeByName), Rcpp::XPtr<GPB::Descriptor> d, std::string nam){
-	return d->FindNestedTypeByName( nam ) ;
+RPB_FUNCTION_2(S4_Descriptor, METHOD(FindNestedTypeByName),
+               Rcpp::XPtr<GPB::Descriptor> d, std::string nam) {
+    return d->FindNestedTypeByName(nam);
 }
 
-RPB_FUNCTION_2( S4_EnumDescriptor, METHOD(enum_type), Rcpp::XPtr<GPB::Descriptor> d, int i){
-	return d->enum_type( i ) ;
+RPB_FUNCTION_2(S4_EnumDescriptor, METHOD(enum_type),
+               Rcpp::XPtr<GPB::Descriptor> d, int i) {
+    return d->enum_type(i);
 }
 
 // FIXME: two methods cant have the same name
-// RPB_FUNCTION_2( S4_EnumDescriptor, METHOD(enum_type), Rcpp::XPtr<GPB::Descriptor> d, std::string name){
+// RPB_FUNCTION_2( S4_EnumDescriptor, METHOD(enum_type),
+// Rcpp::XPtr<GPB::Descriptor> d, std::string name){
 // 	return d->FindEnumTypeByName( i ) ;
 // }
 
-RPB_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::Descriptor> desc){
-	return S4_FileDescriptor( desc->file() ); 
+RPB_FUNCTION_1(S4_FileDescriptor, METHOD(fileDescriptor),
+               Rcpp::XPtr<GPB::Descriptor> desc) {
+    return S4_FileDescriptor(desc->file());
 }
 
-RPB_FUNCTION_2( std::string, METHOD(name), Rcpp::XPtr<GPB::Descriptor> d, bool full){
-	return full ? d->full_name() : d->name() ;
+RPB_FUNCTION_2(std::string, METHOD(name), Rcpp::XPtr<GPB::Descriptor> d,
+               bool full) {
+    return full ? d->full_name() : d->name();
 }
 
-RPB_FUNCTION_2( S4_Message, METHOD(readMessageFromFile), Rcpp::XPtr<GPB::Descriptor> desc, std::string filename ){
-	/* open the file to read in binary mode */
-	int file = open( filename.c_str() , O_RDONLY | O_BINARY);
-	
-	/* create a prototype of the message we are going to read */
-	GPB::Message* message = PROTOTYPE( desc ) ; 
-	if( !message ){
-		throw std::range_error( "could not call factory->GetPrototype(desc)->New()" ) ; 
-	}
-	
-	/* read the message from the file */
-	message->ParsePartialFromFileDescriptor( file ); 
-	close( file ) ;
-	return( S4_Message( message ) ) ;
+RPB_FUNCTION_2(S4_Message, METHOD(readMessageFromFile),
+               Rcpp::XPtr<GPB::Descriptor> desc, std::string filename) {
+    /* open the file to read in binary mode */
+    int file = open(filename.c_str(), O_RDONLY | O_BINARY);
+
+    /* create a prototype of the message we are going to read */
+    GPB::Message* message = PROTOTYPE(desc);
+    if (!message) {
+        throw std::range_error(
+            "could not call factory->GetPrototype(desc)->New()");
+    }
+
+    /* read the message from the file */
+    message->ParsePartialFromFileDescriptor(file);
+    close(file);
+    return (S4_Message(message));
 }
 
-RPB_FUNCTION_2( S4_Message, METHOD(readMessageFromConnection), Rcpp::XPtr<GPB::Descriptor> desc, int conn_id ){
-	RconnectionCopyingInputStream wrapper( conn_id ) ;
-	GPB::io::CopyingInputStreamAdaptor stream( &wrapper ) ;
-	GPB::io::CodedInputStream coded_stream(&stream ) ;
-	
-	/* create a prototype of the message we are going to read */
-	GPB::Message* message = PROTOTYPE( desc ) ; 
-	if( !message ){
-		throw std::range_error( "could not call factory->GetPrototype(desc)->New()" ) ; 
-	}
-	message->ParsePartialFromCodedStream( &coded_stream) ;
-	
-	S4_Message res( message ) ;
-	return res ;
+RPB_FUNCTION_2(S4_Message, METHOD(readMessageFromConnection),
+               Rcpp::XPtr<GPB::Descriptor> desc, int conn_id) {
+    RconnectionCopyingInputStream wrapper(conn_id);
+    GPB::io::CopyingInputStreamAdaptor stream(&wrapper);
+    GPB::io::CodedInputStream coded_stream(&stream);
+
+    /* create a prototype of the message we are going to read */
+    GPB::Message* message = PROTOTYPE(desc);
+    if (!message) {
+        throw std::range_error(
+            "could not call factory->GetPrototype(desc)->New()");
+    }
+    message->ParsePartialFromCodedStream(&coded_stream);
+
+    S4_Message res(message);
+    return res;
 }
 
-RPB_FUNCTION_2( S4_Message, METHOD(readMessageFromRawVector), Rcpp::XPtr<GPB::Descriptor> desc, Rcpp::RawVector raw){
-	GPB::io::ArrayInputStream ais( (void*)raw.begin(), raw.size() ); 
-	GPB::io::CodedInputStream stream( &ais ) ; 
-	
-	GPB::Message* message = PROTOTYPE( desc ) ; 
-	if( !message ){
-		throw std::range_error( "could not call factory->GetPrototype(desc)->New()" ) ; 
-	}
-	
-	message->MergePartialFromCodedStream( &stream ) ;
-	return( S4_Message( message ) ) ;
+RPB_FUNCTION_2(S4_Message, METHOD(readMessageFromRawVector),
+               Rcpp::XPtr<GPB::Descriptor> desc, Rcpp::RawVector raw) {
+    GPB::io::ArrayInputStream ais((void*)raw.begin(), raw.size());
+    GPB::io::CodedInputStream stream(&ais);
+
+    GPB::Message* message = PROTOTYPE(desc);
+    if (!message) {
+        throw std::range_error(
+            "could not call factory->GetPrototype(desc)->New()");
+    }
+
+    message->MergePartialFromCodedStream(&stream);
+    return (S4_Message(message));
 }
 
-RPB_FUNCTION_2( S4_Message, METHOD(readASCIIFromString), Rcpp::XPtr<GPB::Descriptor> desc, std::string input){
-	GPB::Message* message = PROTOTYPE( desc ) ; 
-	if (GPB::TextFormat::ParseFromString( input, message ) ) {
-		return( S4_Message( message ) ) ;
-	} else {
-		throw std::range_error("Could not parse ASCII protocol buffer from text string.");
-	}
+RPB_FUNCTION_2(S4_Message, METHOD(readASCIIFromString),
+               Rcpp::XPtr<GPB::Descriptor> desc, std::string input) {
+    GPB::Message* message = PROTOTYPE(desc);
+    if (GPB::TextFormat::ParseFromString(input, message)) {
+        return (S4_Message(message));
+    } else {
+        throw std::range_error(
+            "Could not parse ASCII protocol buffer from text string.");
+    }
 }
 
-RPB_FUNCTION_2( S4_Message, METHOD(readASCIIFromConnection), Rcpp::XPtr<GPB::Descriptor> desc, int conn_id){
-	RconnectionCopyingInputStream wrapper( conn_id ) ;
-	GPB::io::CopyingInputStreamAdaptor stream( &wrapper ) ;
+RPB_FUNCTION_2(S4_Message, METHOD(readASCIIFromConnection),
+               Rcpp::XPtr<GPB::Descriptor> desc, int conn_id) {
+    RconnectionCopyingInputStream wrapper(conn_id);
+    GPB::io::CopyingInputStreamAdaptor stream(&wrapper);
 
-	/* create a prototype of the message we are going to read */
-	GPB::Message* message = PROTOTYPE( desc ) ;
-	if( !message ){
-		throw std::range_error( "could not call factory->GetPrototype(desc)->New()" ) ; 
-	}
-        if (!GPB::TextFormat::Parse( &stream, message ) ) {
-		throw std::range_error("Could not parse ASCII protocol buffer.");
-        } else {
-                if (wrapper.Failure()) {
-			throw std::range_error("Could not read ASCII protocol buffer.");
-                }
-                return( S4_Message( message ) );
+    /* create a prototype of the message we are going to read */
+    GPB::Message* message = PROTOTYPE(desc);
+    if (!message) {
+        throw std::range_error(
+            "could not call factory->GetPrototype(desc)->New()");
+    }
+    if (!GPB::TextFormat::Parse(&stream, message)) {
+        throw std::range_error("Could not parse ASCII protocol buffer.");
+    } else {
+        if (wrapper.Failure()) {
+            throw std::range_error("Could not read ASCII protocol buffer.");
         }
+        return (S4_Message(message));
+    }
 }
 
 #undef METHOD
 
-} // namespace rprotobuf
+}  // namespace rprotobuf

Modified: pkg/src/wrapper_EnumDescriptor.cpp
===================================================================
--- pkg/src/wrapper_EnumDescriptor.cpp	2013-12-27 23:42:11 UTC (rev 618)
+++ pkg/src/wrapper_EnumDescriptor.cpp	2013-12-27 23:44:50 UTC (rev 619)
@@ -22,57 +22,62 @@
 #include "rprotobuf.h"
 #include "RcppMacros.h"
 
-namespace rprotobuf{
+namespace rprotobuf {
 
 #undef METHOD
-#define METHOD(__NAME__) RCPP_PP_CAT(EnumDescriptor__,__NAME__)	
+#define METHOD(__NAME__) RCPP_PP_CAT(EnumDescriptor__, __NAME__)
 
-	RPB_XP_METHOD_0(METHOD(as_character), GPB::EnumDescriptor      , DebugString) ;
-	RPB_XP_METHOD_0(METHOD(length)      ,GPB::EnumDescriptor,value_count)
-	RPB_XP_METHOD_0(METHOD(value_count) ,GPB::EnumDescriptor,value_count)
-	
-	RPB_FUNCTION_1(S4_Descriptor, METHOD(containing_type), Rcpp::XPtr<GPB::EnumDescriptor> d ){
-		return S4_Descriptor( d->containing_type() ) ;
-	}
+RPB_XP_METHOD_0(METHOD(as_character), GPB::EnumDescriptor, DebugString);
+RPB_XP_METHOD_0(METHOD(length), GPB::EnumDescriptor, value_count)
+RPB_XP_METHOD_0(METHOD(value_count), GPB::EnumDescriptor, value_count)
 
-	RPB_FUNCTION_2( S4_EnumValueDescriptor, METHOD(getValueByIndex) , Rcpp::XPtr<GPB::EnumDescriptor> d, int index){
-		if ((index >= 0) && (index < d->value_count())) {
-		return S4_EnumValueDescriptor( d->value(index) ) ;
-		} else {
-			return S4_EnumValueDescriptor(NULL);
-		}
-	}
-	
-	RPB_FUNCTION_2( S4_EnumValueDescriptor, METHOD(getValueByNumber), Rcpp::XPtr<GPB::EnumDescriptor> d, int i ){
-		return S4_EnumValueDescriptor( d->FindValueByNumber(i)  ) ;                  
-	}
-	RPB_FUNCTION_2( S4_EnumValueDescriptor, METHOD(getValueByName)  ,  Rcpp::XPtr<GPB::EnumDescriptor> d , std::string name ){
-		return S4_EnumValueDescriptor( d->FindValueByName(name) ) ;
-	}
+RPB_FUNCTION_1(S4_Descriptor, METHOD(containing_type),
+               Rcpp::XPtr<GPB::EnumDescriptor> d) {
+    return S4_Descriptor(d->containing_type());
+}
 
-	RPB_FUNCTION_1(S4_Message, METHOD(as_Message), Rcpp::XPtr<GPB::EnumDescriptor> d ){
-		GPB::EnumDescriptorProto* message = new GPB::EnumDescriptorProto() ; 
-		d->CopyTo( message ); 
-		return S4_Message(message) ;
-	}
-	
+RPB_FUNCTION_2(S4_EnumValueDescriptor, METHOD(getValueByIndex),
+               Rcpp::XPtr<GPB::EnumDescriptor> d, int index) {
+    if ((index >= 0) && (index < d->value_count())) {
+        return S4_EnumValueDescriptor(d->value(index));
+    } else {
+        return S4_EnumValueDescriptor(NULL);
+    }
+}
+
+RPB_FUNCTION_2(S4_EnumValueDescriptor, METHOD(getValueByNumber),
+               Rcpp::XPtr<GPB::EnumDescriptor> d, int i) {
+    return S4_EnumValueDescriptor(d->FindValueByNumber(i));
+}
+RPB_FUNCTION_2(S4_EnumValueDescriptor, METHOD(getValueByName),
+               Rcpp::XPtr<GPB::EnumDescriptor> d, std::string name) {
+    return S4_EnumValueDescriptor(d->FindValueByName(name));
+}
+
+RPB_FUNCTION_1(S4_Message, METHOD(as_Message),
+               Rcpp::XPtr<GPB::EnumDescriptor> d) {
+    GPB::EnumDescriptorProto* message = new GPB::EnumDescriptorProto();
+    d->CopyTo(message);
+    return S4_Message(message);
+}
+
 /**
  * Get the value of the enum called name
  *
  * @param xp external pointer to an EnumDescriptor
  * @param name the name of the enum
- * 
+ *
  * @param the value associated with the name
  */
-RPB_FUNCTION_2(int,get_value_of_enum, 
-	Rcpp::XPtr<GPB::EnumDescriptor> d, std::string name){
-	
-	const GPB::EnumValueDescriptor* evd = d->FindValueByName(name) ;
-    if( !evd ){
-    	/* or maybe it should just be NA */
-	Rcpp::stop("cannot get the value");
+RPB_FUNCTION_2(int, get_value_of_enum, Rcpp::XPtr<GPB::EnumDescriptor> d,
+               std::string name) {
+
+    const GPB::EnumValueDescriptor* evd = d->FindValueByName(name);
+    if (!evd) {
+        /* or maybe it should just be NA */
+        Rcpp::stop("cannot get the value");
     }
-	return evd->number(); 
+    return evd->number();
 }
 
 /**
@@ -82,48 +87,52 @@
  * @param name the name of the enum
  * @return logical
  */
-RPB_FUNCTION_2(bool,has_enum_name,
-                Rcpp::XPtr<GPB::EnumDescriptor> d, std::string name){
-       const GPB::EnumValueDescriptor* evd = d->FindValueByName(name) ;
-       return (evd != NULL);
+RPB_FUNCTION_2(bool, has_enum_name, Rcpp::XPtr<GPB::EnumDescriptor> d,
+               std::string name) {
+    const GPB::EnumValueDescriptor* evd = d->FindValueByName(name);
+    return (evd != NULL);
 }
 
 /**
  * @param xp external pointer to a Descriptor
  * @return the descriptor as an R list
  */
-RPB_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; 
+RPB_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;
 }
 
-RPB_FUNCTION_1( Rcpp::CharacterVector, METHOD(getConstantNames), Rcpp::XPtr<GPB::EnumDescriptor> d){
-	int n = d->value_count() ;
-	Rcpp::CharacterVector res( n) ;
-	for( int i=0; i<n; i++){
-		res[i] = d->value(i)->name() ;
-	}
-	return res ;
+RPB_FUNCTION_1(Rcpp::CharacterVector, METHOD(getConstantNames),
+               Rcpp::XPtr<GPB::EnumDescriptor> d) {
+    int n = d->value_count();
+    Rcpp::CharacterVector res(n);
+    for (int i = 0; i < n; i++) {
+        res[i] = d->value(i)->name();
+    }
+    return res;
 }
 
-RPB_FUNCTION_1( S4_FileDescriptor, METHOD(fileDescriptor), Rcpp::XPtr<GPB::EnumDescriptor> desc){
-	return S4_FileDescriptor( desc->file() ); 
+RPB_FUNCTION_1(S4_FileDescriptor, METHOD(fileDescriptor),
+               Rcpp::XPtr<GPB::EnumDescriptor> desc) {
+    return S4_FileDescriptor(desc->file());
 }
 
-RPB_FUNCTION_2( std::string, METHOD(name), Rcpp::XPtr<GPB::EnumDescriptor> d, bool full){
-	return full ? d->full_name() : d->name() ;
+RPB_FUNCTION_2(std::string, METHOD(name), Rcpp::XPtr<GPB::EnumDescriptor> d,
+               bool full) {
+    return full ? d->full_name() : d->name();
 }
 
 #undef METHOD
 
-} // namespace rprotobuf
+}  // namespace rprotobuf



More information about the Rprotobuf-commits mailing list