[Rprotobuf-commits] r637 - pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 30 21:34:11 CET 2013


Author: murray
Date: 2013-12-30 21:34:10 +0100 (Mon, 30 Dec 2013)
New Revision: 637

Modified:
   pkg/src/DescriptorPoolLookup.cpp
   pkg/src/extensions.cpp
Log:
Whitespace change only (clang-format).
* Consistent indentation and wrap at 80 chars.



Modified: pkg/src/DescriptorPoolLookup.cpp
===================================================================
--- pkg/src/DescriptorPoolLookup.cpp	2013-12-30 20:32:52 UTC (rev 636)
+++ pkg/src/DescriptorPoolLookup.cpp	2013-12-30 20:34:10 UTC (rev 637)
@@ -22,60 +22,60 @@
 #include "rprotobuf.h"
 #include "DescriptorPoolLookup.h"
 
-namespace rprotobuf{
-	
-	void DescriptorPoolLookup::add( const std::string& element){
-		elements.insert( element ); 
-	}
-	
-	bool DescriptorPoolLookup::contains( const std::string& element ){
-		return elements.find( element ) != elements.end() ;
-	}
-	
-	SEXP DescriptorPoolLookup::getElements(){
-		return Rcpp::wrap(elements) ;
-	}
-	
-	std::set<std::string> DescriptorPoolLookup::elements ;
-	RWarningErrorCollector DescriptorPoolLookup::error_collector ;
-	RSourceTree DescriptorPoolLookup::source_tree ;
-	GPB::compiler::Importer DescriptorPoolLookup::importer(&source_tree, &error_collector) ;
-	GPB::DynamicMessageFactory DescriptorPoolLookup::message_factory(importer.pool()) ;
-	
-	void DescriptorPoolLookup::importProtoFiles(SEXP files, SEXP dirs ){
-		source_tree.addDirectories( dirs ) ;
-		int n = LENGTH(files) ;
-		for( int j=0; j < n; j++ ){
-			const GPB::FileDescriptor* file_desc = importer.Import( CHAR(STRING_ELT(files, j)) );
-			if (!file_desc) {
-				Rf_error("Could not load proto file '%s'\n",
-					 CHAR(STRING_ELT(files, j)));
-				continue;
-			}
-		    int ntypes = file_desc->message_type_count() ;
-		    for( int i=0; i<ntypes; i++){
-		    	const GPB::Descriptor* desc = file_desc->message_type( i ) ;
-		    	add( desc->full_name() ); 
-		    	/* should we bother recursing ? */
-		    	/* TODO(mstokely): add top level enums and services? */
-		    }
-		    // add top level extensions!
-		    int nexts = file_desc->extension_count() ;
-		    for( int i=0; i<nexts; i++){
-			const GPB::FieldDescriptor* field_desc = file_desc->extension( i ) ;
-			add( field_desc->full_name() );
-		    }
-		}
-		// source_tree.removeDirectories( dirs ) ;
-	}
-	
-	const GPB::DescriptorPool* DescriptorPoolLookup::pool(){
-		return importer.pool() ;
-	}
-	
-	const GPB::DynamicMessageFactory* DescriptorPoolLookup::factory(){
-		return &message_factory ;
-	}
-	
-	
-} // namespace rprotobuf
+namespace rprotobuf {
+
+void DescriptorPoolLookup::add(const std::string& element) {
+    elements.insert(element);
+}
+
+bool DescriptorPoolLookup::contains(const std::string& element) {
+    return elements.find(element) != elements.end();
+}
+
+SEXP DescriptorPoolLookup::getElements() { return Rcpp::wrap(elements); }
+
+std::set<std::string> DescriptorPoolLookup::elements;
+RWarningErrorCollector DescriptorPoolLookup::error_collector;
+RSourceTree DescriptorPoolLookup::source_tree;
+GPB::compiler::Importer DescriptorPoolLookup::importer(&source_tree,
+                                                       &error_collector);
+GPB::DynamicMessageFactory DescriptorPoolLookup::message_factory(
+    importer.pool());
+
+void DescriptorPoolLookup::importProtoFiles(SEXP files, SEXP dirs) {
+    source_tree.addDirectories(dirs);
+    int n = LENGTH(files);
+    for (int j = 0; j < n; j++) {
+        const GPB::FileDescriptor* file_desc =
+            importer.Import(CHAR(STRING_ELT(files, j)));
+        if (!file_desc) {
+            Rf_error("Could not load proto file '%s'\n",
+                     CHAR(STRING_ELT(files, j)));
+            continue;
+        }
+        int ntypes = file_desc->message_type_count();
+        for (int i = 0; i < ntypes; i++) {
+            const GPB::Descriptor* desc = file_desc->message_type(i);
+            add(desc->full_name());
+            /* should we bother recursing ? */
+            /* TODO(mstokely): add top level enums and services? */
+        }
+        // add top level extensions!
+        int nexts = file_desc->extension_count();
+        for (int i = 0; i < nexts; i++) {
+            const GPB::FieldDescriptor* field_desc = file_desc->extension(i);
+            add(field_desc->full_name());
+        }
+    }
+    // source_tree.removeDirectories( dirs ) ;
+}
+
+const GPB::DescriptorPool* DescriptorPoolLookup::pool() {
+    return importer.pool();
+}
+
+const GPB::DynamicMessageFactory* DescriptorPoolLookup::factory() {
+    return &message_factory;
+}
+
+}  // namespace rprotobuf

Modified: pkg/src/extensions.cpp
===================================================================
--- pkg/src/extensions.cpp	2013-12-30 20:32:52 UTC (rev 636)
+++ pkg/src/extensions.cpp	2013-12-30 20:34:10 UTC (rev 637)
@@ -25,30 +25,30 @@
 
 namespace rprotobuf {
 
-RcppExport SEXP getExtension( SEXP pointer, SEXP sfielddesc){
-        /* grab the Message pointer */
-	Rcpp::XPtr<GPB::Message> message(pointer) ;
-	const Reflection * ref = message->GetReflection() ;
-        const GPB::FieldDescriptor* field_desc =
-		GET_FIELD_DESCRIPTOR_POINTER_FROM_S4(sfielddesc);
+RcppExport SEXP getExtension(SEXP pointer, SEXP sfielddesc) {
+    /* grab the Message pointer */
+    Rcpp::XPtr<GPB::Message> message(pointer);
+    const Reflection* ref = message->GetReflection();
+    const GPB::FieldDescriptor* field_desc =
+        GET_FIELD_DESCRIPTOR_POINTER_FROM_S4(sfielddesc);
 
-	// extractFieldAsSEXP returns a default (e.g. 0) even when
-	// field doesn't exist, but returning NULL probably makes more
-	// sense.
-	//
-	// TODO(mstokely): move this logic into extractField so that
-	// all fields get this updated behavior, not just extensions.
+    // extractFieldAsSEXP returns a default (e.g. 0) even when
+    // field doesn't exist, but returning NULL probably makes more
+    // sense.
+    //
+    // TODO(mstokely): move this logic into extractField so that
+    // all fields get this updated behavior, not just extensions.
 
-	if (field_desc->is_repeated()) {
-	  if (ref->FieldSize(*message, field_desc) < 1) {
-	    return R_NilValue;
-	  }
-	} else {
-	  if (!ref->HasField(*message, field_desc)) {
-	    return R_NilValue;
-	  }
-	}
-	return( extractFieldAsSEXP(message, field_desc) );
+    if (field_desc->is_repeated()) {
+        if (ref->FieldSize(*message, field_desc) < 1) {
+            return R_NilValue;
+        }
+    } else {
+        if (!ref->HasField(*message, field_desc)) {
+            return R_NilValue;
+        }
+    }
+    return (extractFieldAsSEXP(message, field_desc));
 }
 
 }  // namespace rprotobuf



More information about the Rprotobuf-commits mailing list