[Rprotobuf-commits] r652 - pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 30 23:23:45 CET 2013


Author: murray
Date: 2013-12-30 23:23:44 +0100 (Mon, 30 Dec 2013)
New Revision: 652

Modified:
   pkg/src/ConnectionOutputStream.cpp
   pkg/src/DescriptorPoolLookup.cpp
   pkg/src/RSourceTree.cpp
   pkg/src/RWarningErrorCollector.cpp
   pkg/src/ZeroCopyInputStreamWrapper.cpp
   pkg/src/ZeroCopyOutputStreamWrapper.cpp
   pkg/src/extensions.cpp
   pkg/src/lookup.cpp
   pkg/src/rprotobuf.cpp
   pkg/src/streams.cpp
   pkg/src/wrapper_ArrayInputStream.cpp
   pkg/src/wrapper_ArrayOutputStream.cpp
   pkg/src/wrapper_Descriptor.cpp
   pkg/src/wrapper_EnumDescriptor.cpp
   pkg/src/wrapper_EnumValueDescriptor.cpp
   pkg/src/wrapper_FieldDescriptor.cpp
   pkg/src/wrapper_FileDescriptor.cpp
   pkg/src/wrapper_Message.cpp
   pkg/src/wrapper_MethodDescriptor.cpp
   pkg/src/wrapper_ServiceDescriptor.cpp
   pkg/src/wrapper_ZeroCopyInputStream.cpp
Log:
whitespace change only.

Increase line-wrap limit to 100 characters.  This is more readable for
this code base as the large method names force too many conditionals
and assignments onto far too many lines, and it more closely matches
the previous style.

There are still a fair number of lines greater than 100 characters
that are wrapped.



Modified: pkg/src/ConnectionOutputStream.cpp
===================================================================
--- pkg/src/ConnectionOutputStream.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/ConnectionOutputStream.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -5,8 +5,7 @@
 namespace rprotobuf {
 
 ConnectionOutputStream::ConnectionOutputStream(SEXP con, bool was_open)
-    : GPB::io::CopyingOutputStreamAdaptor(
-          new ConnectionCopyingOutputStream(con)),
+    : GPB::io::CopyingOutputStreamAdaptor(new ConnectionCopyingOutputStream(con)),
       was_open(was_open),
       con(con) {
     /* clean the wrapped stream on delete */

Modified: pkg/src/DescriptorPoolLookup.cpp
===================================================================
--- pkg/src/DescriptorPoolLookup.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/DescriptorPoolLookup.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -22,9 +22,7 @@
 
 namespace rprotobuf {
 
-void DescriptorPoolLookup::add(const std::string& element) {
-    elements.insert(element);
-}
+void DescriptorPoolLookup::add(const std::string& element) { elements.insert(element); }
 
 bool DescriptorPoolLookup::contains(const std::string& element) {
     return elements.find(element) != elements.end();
@@ -35,20 +33,16 @@
 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());
+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)));
+        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)));
+            Rf_error("Could not load proto file '%s'\n", CHAR(STRING_ELT(files, j)));
             continue;
         }
         int ntypes = file_desc->message_type_count();
@@ -68,12 +62,8 @@
     // source_tree.removeDirectories( dirs ) ;
 }
 
-const GPB::DescriptorPool* DescriptorPoolLookup::pool() {
-    return importer.pool();
-}
+const GPB::DescriptorPool* DescriptorPoolLookup::pool() { return importer.pool(); }
 
-const GPB::DynamicMessageFactory* DescriptorPoolLookup::factory() {
-    return &message_factory;
-}
+const GPB::DynamicMessageFactory* DescriptorPoolLookup::factory() { return &message_factory; }
 
 }  // namespace rprotobuf

Modified: pkg/src/RSourceTree.cpp
===================================================================
--- pkg/src/RSourceTree.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/RSourceTree.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -27,15 +27,12 @@
         return NULL;
     }
 
-    GPB::io::FileInputStream* result =
-        new GPB::io::FileInputStream(file_descriptor);
+    GPB::io::FileInputStream* result = new GPB::io::FileInputStream(file_descriptor);
     result->SetCloseOnDelete(true);
     return result;
 }
 
-void RSourceTree::addDirectory(const std::string& directory) {
-    directories.insert(directory);
-}
+void RSourceTree::addDirectory(const std::string& directory) { directories.insert(directory); }
 void RSourceTree::addDirectories(SEXP dirs) {
     int n = LENGTH(dirs);
     for (int i = 0; i < n; i++) {
@@ -43,9 +40,7 @@
     }
 }
 
-void RSourceTree::removeDirectory(const std::string& directory) {
-    directories.erase(directory);
-}
+void RSourceTree::removeDirectory(const std::string& directory) { directories.erase(directory); }
 void RSourceTree::removeDirectories(SEXP dirs) {
     int n = LENGTH(dirs);
     for (int i = 0; i < n; i++) {

Modified: pkg/src/RWarningErrorCollector.cpp
===================================================================
--- pkg/src/RWarningErrorCollector.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/RWarningErrorCollector.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -3,11 +3,10 @@
 
 namespace rprotobuf {
 
-void RWarningErrorCollector::AddError(const std::string& filename, int line,
-                                      int column, const std::string& message) {
+void RWarningErrorCollector::AddError(const std::string& filename, int line, int column,
+                                      const std::string& message) {
 
-    Rprintf("%s:%d:%d:%s\n", filename.c_str(), line + 1, column + 1,
-            message.c_str());
+    Rprintf("%s:%d:%d:%s\n", filename.c_str(), line + 1, column + 1, message.c_str());
 }
 
 }  // namespace rprotobuf

Modified: pkg/src/ZeroCopyInputStreamWrapper.cpp
===================================================================
--- pkg/src/ZeroCopyInputStreamWrapper.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/ZeroCopyInputStreamWrapper.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -2,8 +2,7 @@
 
 namespace rprotobuf {
 
-ZeroCopyInputStreamWrapper::ZeroCopyInputStreamWrapper(
-    GPB::io::ZeroCopyInputStream* stream)
+ZeroCopyInputStreamWrapper::ZeroCopyInputStreamWrapper(GPB::io::ZeroCopyInputStream* stream)
     : stream(stream) {
     coded_stream = new GPB::io::CodedInputStream(stream);
 }
@@ -15,11 +14,7 @@
     /* then the stream itself */
     delete stream;
 }
-GPB::io::ZeroCopyInputStream* ZeroCopyInputStreamWrapper::get_stream() {
-    return stream;
-}
-GPB::io::CodedInputStream* ZeroCopyInputStreamWrapper::get_coded_stream() {
-    return coded_stream;
-}
+GPB::io::ZeroCopyInputStream* ZeroCopyInputStreamWrapper::get_stream() { return stream; }
+GPB::io::CodedInputStream* ZeroCopyInputStreamWrapper::get_coded_stream() { return coded_stream; }
 
 }  // namespace rprotobuf

Modified: pkg/src/ZeroCopyOutputStreamWrapper.cpp
===================================================================
--- pkg/src/ZeroCopyOutputStreamWrapper.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/ZeroCopyOutputStreamWrapper.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -2,8 +2,7 @@
 
 namespace rprotobuf {
 
-ZeroCopyOutputStreamWrapper::ZeroCopyOutputStreamWrapper(
-    GPB::io::ZeroCopyOutputStream* stream)
+ZeroCopyOutputStreamWrapper::ZeroCopyOutputStreamWrapper(GPB::io::ZeroCopyOutputStream* stream)
     : stream(stream) {
     coded_stream = new GPB::io::CodedOutputStream(stream);
 }
@@ -15,11 +14,7 @@
     /* then the stream itself */
     delete stream;
 }
-GPB::io::ZeroCopyOutputStream* ZeroCopyOutputStreamWrapper::get_stream() {
-    return stream;
-}
-GPB::io::CodedOutputStream* ZeroCopyOutputStreamWrapper::get_coded_stream() {
-    return coded_stream;
-}
+GPB::io::ZeroCopyOutputStream* ZeroCopyOutputStreamWrapper::get_stream() { return stream; }
+GPB::io::CodedOutputStream* ZeroCopyOutputStreamWrapper::get_coded_stream() { return coded_stream; }
 
 }  // namespace rprotobuf

Modified: pkg/src/extensions.cpp
===================================================================
--- pkg/src/extensions.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/extensions.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -29,8 +29,7 @@
     /* 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);
+    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

Modified: pkg/src/lookup.cpp
===================================================================
--- pkg/src/lookup.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/lookup.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -18,8 +18,7 @@
  *
  * @return _TRUE_ if there is a message of the given type in the DescriptorPool
  */
-Rboolean rProtoBufTable_exists(const char *const name, Rboolean *canCache,
-                               R_ObjectTable *tb) {
+Rboolean rProtoBufTable_exists(const char *const name, Rboolean *canCache, R_ObjectTable *tb) {
 
 #ifdef LOOKUP_DEBUG
     Rprintf("  >> rProtoBufTable_exists\n");
@@ -35,16 +34,15 @@
     } else {
         /* try the generated pool */
         const GPB::DescriptorPool *pool = GPB::DescriptorPool::generated_pool();
-        if (pool->FindMessageTypeByName(name) ||
-            pool->FindEnumTypeByName(name) || pool->FindServiceByName(name) ||
-            pool->FindMethodByName(name) || pool->FindExtensionByName(name)) {
+        if (pool->FindMessageTypeByName(name) || pool->FindEnumTypeByName(name) ||
+            pool->FindServiceByName(name) || pool->FindMethodByName(name) ||
+            pool->FindExtensionByName(name)) {
             DescriptorPoolLookup::add(name);
             val = _TRUE_;
         } else {
             /* try the runtime pool */
             pool = DescriptorPoolLookup::pool();
-            if (pool->FindMessageTypeByName(name) ||
-                pool->FindEnumTypeByName(name) ||
+            if (pool->FindMessageTypeByName(name) || pool->FindEnumTypeByName(name) ||
                 pool->FindServiceByName(name) || pool->FindMethodByName(name) ||
                 pool->FindExtensionByName(name)) {
                 DescriptorPoolLookup::add(name);
@@ -65,29 +63,25 @@
         DescriptorPoolLookup::add(name_string);
         return S4_Descriptor(desc);
     } else {
-        const GPB::EnumDescriptor *enum_desc =
-            pool->FindEnumTypeByName(name_string);
+        const GPB::EnumDescriptor *enum_desc = pool->FindEnumTypeByName(name_string);
         if (enum_desc) {
             /* enum */
             DescriptorPoolLookup::add(name_string);
             return S4_EnumDescriptor(enum_desc);
 
         } else {
-            const GPB::FieldDescriptor *extension_desc =
-                pool->FindExtensionByName(name_string);
+            const GPB::FieldDescriptor *extension_desc = pool->FindExtensionByName(name_string);
             if (extension_desc) {
                 /* extension */
                 DescriptorPoolLookup::add(name_string);
                 return S4_FieldDescriptor(extension_desc);
             } else {
-                const GPB::ServiceDescriptor *service_desc =
-                    pool->FindServiceByName(name_string);
+                const GPB::ServiceDescriptor *service_desc = pool->FindServiceByName(name_string);
                 if (service_desc) {
                     DescriptorPoolLookup::add(name_string);
                     return S4_ServiceDescriptor(service_desc);
                 } else {
-                    const GPB::MethodDescriptor *method_desc =
-                        pool->FindMethodByName(name_string);
+                    const GPB::MethodDescriptor *method_desc = pool->FindMethodByName(name_string);
                     if (method_desc) {
                         DescriptorPoolLookup::add(name_string);
                         return S4_MethodDescriptor(method_desc);
@@ -107,8 +101,7 @@
  * @param canCache
  * @param tb lookup table
  */
-SEXP rProtoBufTable_get(const char *const name, Rboolean *canCache,
-                        R_ObjectTable *tb) {
+SEXP rProtoBufTable_get(const char *const name, Rboolean *canCache, R_ObjectTable *tb) {
 
 #ifdef LOOKUP_DEBUG
     Rprintf("  >> rProtoBufTable_get\n");
@@ -172,8 +165,7 @@
  * NULL to indicate assign is not possible on this lookup table
  * without giving such a hard error.
  */
-SEXP rProtoBufTable_assign(const char *const name, SEXP value,
-                           R_ObjectTable *tb) {
+SEXP rProtoBufTable_assign(const char *const name, SEXP value, R_ObjectTable *tb) {
 #ifdef LOOKUP_DEBUG
     Rprintf("  >> rProtoBufTable_assign( %s ) \n", name);
 #endif
@@ -224,8 +216,7 @@
     tb->onAttach = NULL;
     tb->onDetach = NULL;
 
-    PROTECT(val = R_MakeExternalPtr(tb, Rf_install("UserDefinedDatabase"),
-                                    R_NilValue));
+    PROTECT(val = R_MakeExternalPtr(tb, Rf_install("UserDefinedDatabase"), R_NilValue));
     PROTECT(klass = Rf_mkString("UserDefinedDatabase"));
     Rf_setAttrib(val, R_ClassSymbol, klass);
     UNPROTECT(2); /* val, klass */
@@ -236,8 +227,7 @@
 
     Rcpp::Function fun("attach");
     int pos = Rcpp::as<int>(possexp);
-    fun(val, Rcpp::Named("pos") = pos,
-        Rcpp::Named("name") = "RProtoBuf:DescriptorPool");
+    fun(val, Rcpp::Named("pos") = pos, Rcpp::Named("name") = "RProtoBuf:DescriptorPool");
 
     return (val);
 }

Modified: pkg/src/rprotobuf.cpp
===================================================================
--- pkg/src/rprotobuf.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/rprotobuf.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -10,8 +10,7 @@
     Rprintf("desc = %d\n", desc);
 #endif
     /* first try the runtime factory */
-    GPB::Message* m = (GPB::Message*)((GPB::DynamicMessageFactory*)
-                                      DescriptorPoolLookup::factory())
+    GPB::Message* m = (GPB::Message*)((GPB::DynamicMessageFactory*)DescriptorPoolLookup::factory())
                           ->GetPrototype(desc)
                           ->New();
 
@@ -20,9 +19,7 @@
 #endif
     if (!m) {
         /* then the dynamic runtime factory */
-        m = (GPB::Message*)GPB::MessageFactory::generated_factory()
-                ->GetPrototype(desc)
-                ->New();
+        m = (GPB::Message*)GPB::MessageFactory::generated_factory()->GetPrototype(desc)->New();
 #ifdef RPB_DEBUG
         Rprintf("runtime  factory = %d\n", m);
 #endif
@@ -212,8 +209,7 @@
 
     if (TYPEOF(m) != S4SXP || !Rf_inherits(m, "Message")) return _FALSE_;
 
-    GPB::Message* message =
-        (GPB::Message*)EXTPTR_PTR(GET_SLOT(m, Rf_install("pointer")));
+    GPB::Message* message = (GPB::Message*)EXTPTR_PTR(GET_SLOT(m, Rf_install("pointer")));
 
     const char* type = message->GetDescriptor()->full_name().c_str();
     if (strcmp(type, target)) {
@@ -238,22 +234,18 @@
             break;
         }
         case CHARSXP: {
-            field_desc =
-                (GPB::FieldDescriptor*)desc->FindFieldByName(CHAR(name));
+            field_desc = (GPB::FieldDescriptor*)desc->FindFieldByName(CHAR(name));
             error_message = error_message + " '" + CHAR(name) + "'";
             break;
         }
         case STRSXP: {
-            field_desc = (GPB::FieldDescriptor*)desc->FindFieldByName(
-                CHAR(STRING_ELT(name, 0)));
-            error_message =
-                error_message + " '" + CHAR(STRING_ELT(name, 0)) + "'";
+            field_desc = (GPB::FieldDescriptor*)desc->FindFieldByName(CHAR(STRING_ELT(name, 0)));
+            error_message = error_message + " '" + CHAR(STRING_ELT(name, 0)) + "'";
             break;
         }
         case REALSXP:
         case INTSXP: {
-            field_desc = (GPB::FieldDescriptor*)desc->FindFieldByNumber(
-                Rcpp::as<int>(name));
+            field_desc = (GPB::FieldDescriptor*)desc->FindFieldByNumber(Rcpp::as<int>(name));
             break;
         }
     }
@@ -273,8 +265,6 @@
     }
 }
 
-RPB_FUNCTION_0(int, get_protobuf_library_version) {
-    return GOOGLE_PROTOBUF_VERSION;
-}
+RPB_FUNCTION_0(int, get_protobuf_library_version) { return GOOGLE_PROTOBUF_VERSION; }
 
 }  // namespace rprotobuf

Modified: pkg/src/streams.cpp
===================================================================
--- pkg/src/streams.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/streams.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -6,9 +6,7 @@
 
 namespace rprotobuf {
 
-void ZeroCopyInputStreamWrapper_finalizer(SEXP xp) {
-    delete (ZeroCopyInputStreamWrapper*)XPP(xp);
-}
+void ZeroCopyInputStreamWrapper_finalizer(SEXP xp) { delete (ZeroCopyInputStreamWrapper*)XPP(xp); }
 void ZeroCopyOutputStreamWrapper_finalizer(SEXP xp) {
     delete (ZeroCopyOutputStreamWrapper*)XPP(xp);
 }
@@ -21,14 +19,11 @@
     NEW_S4_OBJECT("FileInputStream");
     int fd = open(CHAR(STRING_ELT(filename, 0)), O_RDONLY | O_BINARY);
 
-    GPB::io::FileInputStream* stream =
-        new GPB::io::FileInputStream(fd, INTEGER(block_size)[0]);
+    GPB::io::FileInputStream* stream = new GPB::io::FileInputStream(fd, INTEGER(block_size)[0]);
     stream->SetCloseOnDelete(LOGICAL(close_on_delete)[0]);
-    ZeroCopyInputStreamWrapper* wrapper =
-        new ZeroCopyInputStreamWrapper(stream);
+    ZeroCopyInputStreamWrapper* wrapper = new ZeroCopyInputStreamWrapper(stream);
 
-    SEXP ptr =
-        PROTECT(R_MakeExternalPtr((void*)wrapper, R_NilValue, R_NilValue));
+    SEXP ptr = PROTECT(R_MakeExternalPtr((void*)wrapper, R_NilValue, R_NilValue));
     R_RegisterCFinalizerEx(ptr, ZeroCopyInputStreamWrapper_finalizer, _FALSE_);
     SET_SLOT(oo, Rf_install("pointer"), ptr);
 
@@ -54,10 +49,8 @@
 // {{{ ConnectionInputStream
 SEXP ConnectionInputStream_new(SEXP con, SEXP was_open) {
     NEW_S4_OBJECT("ConnectionInputStream");
-    ConnectionInputStream* stream =
-        new ConnectionInputStream(con, (bool)LOGICAL(was_open)[0]);
-    ZeroCopyInputStreamWrapper* wrapper =
-        new ZeroCopyInputStreamWrapper(stream);
+    ConnectionInputStream* stream = new ConnectionInputStream(con, (bool)LOGICAL(was_open)[0]);
+    ZeroCopyInputStreamWrapper* wrapper = new ZeroCopyInputStreamWrapper(stream);
     SEXP ptr = PROTECT(R_MakeExternalPtr((void*)wrapper, R_NilValue, con));
     R_RegisterCFinalizerEx(ptr, ZeroCopyInputStreamWrapper_finalizer, _FALSE_);
     SET_SLOT(oo, Rf_install("pointer"), ptr);
@@ -97,20 +90,15 @@
 // {{{ ArrayOutputStream
 // }}}
 // {{{ FileOutputStream
-SEXP FileOutputStream_new(SEXP filename, SEXP block_size,
-                          SEXP close_on_delete) {
+SEXP FileOutputStream_new(SEXP filename, SEXP block_size, SEXP close_on_delete) {
     NEW_S4_OBJECT("FileOutputStream");
-    int fd = open(CHAR(STRING_ELT(filename, 0)),
-                  O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
+    int fd = open(CHAR(STRING_ELT(filename, 0)), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
 
-    GPB::io::FileOutputStream* stream =
-        new GPB::io::FileOutputStream(fd, INTEGER(block_size)[0]);
+    GPB::io::FileOutputStream* stream = new GPB::io::FileOutputStream(fd, INTEGER(block_size)[0]);
     stream->SetCloseOnDelete(LOGICAL(close_on_delete)[0]);
-    ZeroCopyOutputStreamWrapper* wrapper =
-        new ZeroCopyOutputStreamWrapper(stream);
+    ZeroCopyOutputStreamWrapper* wrapper = new ZeroCopyOutputStreamWrapper(stream);
 
-    SEXP ptr =
-        PROTECT(R_MakeExternalPtr((void*)wrapper, R_NilValue, R_NilValue));
+    SEXP ptr = PROTECT(R_MakeExternalPtr((void*)wrapper, R_NilValue, R_NilValue));
     R_RegisterCFinalizerEx(ptr, ZeroCopyOutputStreamWrapper_finalizer, _FALSE_);
     SET_SLOT(oo, Rf_install("pointer"), ptr);
 
@@ -140,10 +128,8 @@
 // {{{ ConnectionOutputStream
 SEXP ConnectionOutputStream_new(SEXP con, SEXP was_open) {
     NEW_S4_OBJECT("ConnectionOutputStream");
-    ConnectionOutputStream* stream =
-        new ConnectionOutputStream(con, (bool)LOGICAL(was_open)[0]);
-    ZeroCopyOutputStreamWrapper* wrapper =
-        new ZeroCopyOutputStreamWrapper(stream);
+    ConnectionOutputStream* stream = new ConnectionOutputStream(con, (bool)LOGICAL(was_open)[0]);
+    ZeroCopyOutputStreamWrapper* wrapper = new ZeroCopyOutputStreamWrapper(stream);
     /* we keep the R connection protected as long as the
        external pointer is kept out of GC */
     SEXP ptr = PROTECT(R_MakeExternalPtr((void*)wrapper, R_NilValue, con));
@@ -162,8 +148,7 @@
     GPB::io::CodedInputStream* coded_stream = GET_CIS(xp);
     int s = INTEGER(size)[0];
     SEXP payload = PROTECT(Rf_allocVector(RAWSXP, s));
-    if (!coded_stream->ReadRaw(RAW(payload), s))
-        Rf_error("error reading raw bytes");
+    if (!coded_stream->ReadRaw(RAW(payload), s)) Rf_error("error reading raw bytes");
     UNPROTECT(1); /* payload */
     return payload;
 }
@@ -187,16 +172,14 @@
 SEXP ZeroCopyInputStream_ReadLittleEndian32(SEXP xp) {
     GPB::io::CodedInputStream* coded_stream = GET_CIS(xp);
     uint32 res = 0;
-    if (!coded_stream->ReadVarint32(&res))
-        Rf_error("error reading little endian int32");
+    if (!coded_stream->ReadVarint32(&res)) Rf_error("error reading little endian int32");
     return Rf_ScalarInteger(res);
 }
 
 SEXP ZeroCopyInputStream_ReadLittleEndian64(SEXP xp) {
     GPB::io::CodedInputStream* coded_stream = GET_CIS(xp);
     uint64 res = 0;
-    if (!coded_stream->ReadVarint64(&res))
-        Rf_error("error reading little endian int32");
+    if (!coded_stream->ReadVarint64(&res)) Rf_error("error reading little endian int32");
     return Rf_ScalarReal((double)res);
 }
 

Modified: pkg/src/wrapper_ArrayInputStream.cpp
===================================================================
--- pkg/src/wrapper_ArrayInputStream.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/wrapper_ArrayInputStream.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -4,8 +4,8 @@
 
 namespace rprotobuf {
 
-RPB_FUNCTION_2(S4_ArrayInputStream, ArrayInputStream__new,
-               Rcpp::RawVector payload, int block_size) {
+RPB_FUNCTION_2(S4_ArrayInputStream, ArrayInputStream__new, Rcpp::RawVector payload,
+               int block_size) {
     return S4_ArrayInputStream(payload, block_size);
 }
 }

Modified: pkg/src/wrapper_ArrayOutputStream.cpp
===================================================================
--- pkg/src/wrapper_ArrayOutputStream.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/wrapper_ArrayOutputStream.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -4,8 +4,7 @@
 
 namespace rprotobuf {
 
-RPB_FUNCTION_2(S4_ArrayOutputStream, ArrayOutputStream__new, int size,
-               int block_size) {
+RPB_FUNCTION_2(S4_ArrayOutputStream, ArrayOutputStream__new, int size, int block_size) {
     return S4_ArrayOutputStream(size, block_size);
 }
 }

Modified: pkg/src/wrapper_Descriptor.cpp
===================================================================
--- pkg/src/wrapper_Descriptor.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/wrapper_Descriptor.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -11,8 +11,7 @@
 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
@@ -22,8 +21,7 @@
  *
  * @return member names, as an R character vector (STRSXP)
  */
-RPB_FUNCTION_1(Rcpp::CharacterVector, METHOD(getMemberNames),
-               Rcpp::XPtr<GPB::Descriptor> desc) {
+RPB_FUNCTION_1(Rcpp::CharacterVector, METHOD(getMemberNames), Rcpp::XPtr<GPB::Descriptor> desc) {
 
     int nfields = desc->field_count();
     int ntypes = desc->nested_type_count();
@@ -84,33 +82,30 @@
     return message;
 }
 
-RPB_FUNCTION_2(S4_FieldDescriptor, METHOD(field), Rcpp::XPtr<GPB::Descriptor> d,
-               int 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) {
+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) {
+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) {
+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) {
+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) {
+RPB_FUNCTION_2(S4_EnumDescriptor, METHOD(enum_type), Rcpp::XPtr<GPB::Descriptor> d, int i) {
     return d->enum_type(i);
 }
 
@@ -120,26 +115,23 @@
 // 	return d->FindEnumTypeByName( i ) ;
 // }
 
-RPB_FUNCTION_1(S4_FileDescriptor, METHOD(fileDescriptor),
-               Rcpp::XPtr<GPB::Descriptor> desc) {
+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) {
+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) {
+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()");
+        throw std::range_error("could not call factory->GetPrototype(desc)->New()");
     }
 
     /* read the message from the file */
@@ -148,8 +140,8 @@
     return (S4_Message(message));
 }
 
-RPB_FUNCTION_2(S4_Message, METHOD(readMessageFromConnection),
-               Rcpp::XPtr<GPB::Descriptor> desc, int conn_id) {
+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);
@@ -157,8 +149,7 @@
     /* 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()");
+        throw std::range_error("could not call factory->GetPrototype(desc)->New()");
     }
     message->ParsePartialFromCodedStream(&coded_stream);
 
@@ -166,42 +157,39 @@
     return res;
 }
 
-RPB_FUNCTION_2(S4_Message, METHOD(readMessageFromRawVector),
-               Rcpp::XPtr<GPB::Descriptor> desc, Rcpp::RawVector raw) {
+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()");
+        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) {
+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.");
+        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) {
+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()");
+        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.");

Modified: pkg/src/wrapper_EnumDescriptor.cpp
===================================================================
--- pkg/src/wrapper_EnumDescriptor.cpp	2013-12-30 21:49:04 UTC (rev 651)
+++ pkg/src/wrapper_EnumDescriptor.cpp	2013-12-30 22:23:44 UTC (rev 652)
@@ -29,13 +29,12 @@
 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) {
+RPB_FUNCTION_1(S4_Descriptor, METHOD(containing_type), Rcpp::XPtr<GPB::EnumDescriptor> d) {
     return S4_Descriptor(d->containing_type());
 }
 
-RPB_FUNCTION_2(S4_EnumValueDescriptor, METHOD(getValueByIndex),
-               Rcpp::XPtr<GPB::EnumDescriptor> d, int index) {
+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 {
@@ -43,17 +42,16 @@
     }
 }
 
-RPB_FUNCTION_2(S4_EnumValueDescriptor, METHOD(getValueByNumber),
-               Rcpp::XPtr<GPB::EnumDescriptor> d, int i) {
+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) {
+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) {
+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);
@@ -67,8 +65,7 @@
  *
  * @param the value associated with the name
  */
-RPB_FUNCTION_2(int, get_value_of_enum, Rcpp::XPtr<GPB::EnumDescriptor> d,
-               std::string 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) {
@@ -85,8 +82,7 @@
  * @param name the name of the enum
  * @return logical
  */
-RPB_FUNCTION_2(bool, has_enum_name, Rcpp::XPtr<GPB::EnumDescriptor> d,
-               std::string name) {
+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);
 }
@@ -95,8 +91,7 @@
  * @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) {
+RPB_FUNCTION_1(Rcpp::IntegerVector, METHOD(as_list), Rcpp::XPtr<GPB::EnumDescriptor> d) {
 
     int n = d->value_count();
     Rcpp::IntegerVector values(n);
@@ -111,8 +106,7 @@
     return values;
 }
 
-RPB_FUNCTION_1(Rcpp::CharacterVector, METHOD(getConstantNames),
-               Rcpp::XPtr<GPB::EnumDescriptor> d) {
+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++) {
@@ -121,13 +115,11 @@
     return res;
 }
 
-RPB_FUNCTION_1(S4_FileDescriptor, METHOD(fileDescriptor),
-               Rcpp::XPtr<GPB::EnumDescriptor> desc) {
+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) {
+RPB_FUNCTION_2(std::string, METHOD(name), Rcpp::XPtr<GPB::EnumDescriptor> d, bool full) {
     return full ? d->full_name() : d->name();
 }
 

[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/rprotobuf -r 652


More information about the Rprotobuf-commits mailing list