[Rprotobuf-commits] r447 - patches

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon May 14 22:42:59 CEST 2012


Author: edd
Date: 2012-05-14 22:42:59 +0200 (Mon, 14 May 2012)
New Revision: 447

Added:
   patches/patch_by_Murray_rprotobuf_r423_424.diff
   patches/patch_by_Murray_rprotobuf_r425.diff
   patches/patch_by_Murray_rprotobuf_r435.diff
Log:
committing three older patches by Murray which had gone into svn trunk but not here


Added: patches/patch_by_Murray_rprotobuf_r423_424.diff
===================================================================
--- patches/patch_by_Murray_rprotobuf_r423_424.diff	                        (rev 0)
+++ patches/patch_by_Murray_rprotobuf_r423_424.diff	2012-05-14 20:42:59 UTC (rev 447)
@@ -0,0 +1,32 @@
+Index: src/wrapper_FileDescriptor.cpp
+===================================================================
+--- src/wrapper_FileDescriptor.cpp      (revision 422)
++++ src/wrapper_FileDescriptor.cpp      (working copy)
+@@ -73,8 +73,8 @@
+        return res;
+ }
+
+-RCPP_FUNCTION_1( std::string, METHOD(name), Rcpp::XPtr<GPB::EnumDescriptor> d ){
+-       return d->full_name() ;
++RCPP_FUNCTION_1( std::string, METHOD(name), Rcpp::XPtr<GPB::FileDescriptor> desc ){
++       return desc->name() ;
+ }
+
+ #undef METHOD
+
+----------------------------------------------------------------------
+Index: src/wrapper_FileDescriptor.cpp
+===================================================================
+--- src/wrapper_FileDescriptor.cpp	(revision 422)
++++ src/wrapper_FileDescriptor.cpp	(working copy)
+@@ -73,8 +73,8 @@
+ 	return res; 
+ }
+ 
+-RCPP_FUNCTION_1( std::string, METHOD(name), Rcpp::XPtr<GPB::EnumDescriptor> d ){
+-	return d->full_name() ;
++RCPP_FUNCTION_1( std::string, METHOD(name), Rcpp::XPtr<GPB::FileDescriptor> desc ){
++	return desc->name() ;
+ }
+ 
+ #undef METHOD

Added: patches/patch_by_Murray_rprotobuf_r425.diff
===================================================================
--- patches/patch_by_Murray_rprotobuf_r425.diff	                        (rev 0)
+++ patches/patch_by_Murray_rprotobuf_r425.diff	2012-05-14 20:42:59 UTC (rev 447)
@@ -0,0 +1,98 @@
+Index: R/read.R
+===================================================================
+--- R/read.R	(revision 424)
++++ R/read.R	(working copy)
+@@ -35,7 +35,7 @@
+ 
+ setMethod( "readASCII", c( descriptor = "Descriptor" , input = "character" ), 
+ function(descriptor, input ){
+-	.Call( "Descriptor__readASCII_FromString", descriptor at pointer, input, PACKAGE = "RProtoBuf" ) 
++	.Call( "Descriptor__readASCIIFromString", descriptor at pointer, input, PACKAGE = "RProtoBuf" ) 
+ } )
+ 
+ setMethod( "readASCII", c( descriptor = "Descriptor" ), 
+@@ -46,8 +46,7 @@
+ 	sc <- summary( input )
+ 	wasopen <- identical( sc[["opened"]], "opened" )
+ 	if( !wasopen ) open( input )
+-	message <- .Call( "Descriptor__readASCII_FromConnection", descriptor at pointer, input, PACKAGE = "RProtoBuf" )
++	message <- .Call( "Descriptor__readASCIIFromConnection", descriptor at pointer, input, PACKAGE = "RProtoBuf" )
+ 	if( !wasopen ) close( input )
+ 	message
+ } )
+-
+Index: src/wrapper_Descriptor.cpp
+===================================================================
+--- src/wrapper_Descriptor.cpp	(revision 424)
++++ src/wrapper_Descriptor.cpp	(working copy)
+@@ -164,12 +164,25 @@
+ 	return( S4_Message( message ) ) ;
+ }
+ 
+-RCPP_FUNCTION_2( S4_Message, METHOD(readASCII_FromString), Rcpp::XPtr<GPB::Descriptor> desc, std::string input){
++RCPP_FUNCTION_2( S4_Message, METHOD(readASCIIFromString), Rcpp::XPtr<GPB::Descriptor> desc, std::string input){
+ 	GPB::Message* message = PROTOTYPE( desc ) ; 
+ 	GPB::TextFormat::ParseFromString( input, message ) ;
+ 	return( S4_Message( message ) ) ;
+ }
+ 
++RCPP_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()" ) ; 
++	}
++	GPB::TextFormat::Parse( &stream, message ) ;
++	return( S4_Message( message ) ) ;
++}
++
+ #undef METHOD
+ 
+ } // namespace rprotobuf
+Index: man/readASCII.Rd
+===================================================================
+--- man/readASCII.Rd	(revision 424)
++++ man/readASCII.Rd	(working copy)
+@@ -20,4 +20,21 @@
+ }
+ }}
+ \keyword{methods}
++\examples{
++# example file that contains a "tutorial.AddressBook" message
++book <- system.file( "examples", "addressbook.pb", package = "RProtoBuf" )
+ 
++# read the message
++message <- read( tutorial.AddressBook, book )
++
++# Output in text format to a temporary file
++out.file <- tempfile()
++writeLines( as.character(message), file(out.file))
++
++# Verify we can read back in the message from a text file.
++message2 <- readASCII( tutorial.AddressBook, file(out.file, "rb"))
++
++\dontshow{
++stopifnot( identical( message, message2) )
++}
++}
+Index: inst/unitTests/runit.addressbook.R
+===================================================================
+--- inst/unitTests/runit.addressbook.R	(revision 424)
++++ inst/unitTests/runit.addressbook.R	(working copy)
+@@ -29,3 +29,13 @@
+     checkEquals(book$person[[2]]$phone[[1]]$number, "+01...",            msg="Second person phone number")
+     checkEquals(book$person[[2]]$phone[[1]]$type,   0,                   msg="Second person phone number")
+ }
++
++test.ascii <- function() {
++    # Output in text format to a temporary file
++    out.file <- tempfile()
++    writeLines( as.character(book), file(out.file))
++
++    # Verify we can read back in the message from a text file.
++    book2 <- readASCII( tutorial.AddressBook, file(out.file, "rb"))
++    checkEquals(book, book2)
++}

Added: patches/patch_by_Murray_rprotobuf_r435.diff
===================================================================
--- patches/patch_by_Murray_rprotobuf_r435.diff	                        (rev 0)
+++ patches/patch_by_Murray_rprotobuf_r435.diff	2012-05-14 20:42:59 UTC (rev 447)
@@ -0,0 +1,43 @@
+Index: DESCRIPTION
+===================================================================
+--- DESCRIPTION	(revision 434)
++++ DESCRIPTION	(working copy)
+@@ -1,5 +1,5 @@
+ Package: RProtoBuf
+-Version: 0.2.4
++Version: 0.2.5
+ Date: $Date$
+ Author: Romain Francois <romain at r-enthusiasts.com> and Dirk Eddelbuettel <edd at debian.org>
+ Maintainer: Romain and Dirk <RomainAndDirk at r-enthusiasts.com>
+Index: src/mutators.cpp
+===================================================================
+--- src/mutators.cpp	(revision 434)
++++ src/mutators.cpp	(working copy)
+@@ -396,6 +396,8 @@
+ 		if( field_type == TYPE_STRING || field_type == TYPE_BYTES ){
+ 			if( TYPEOF(value) == RAWSXP ){
+ 				value_size = 1 ;
++            } else if( TYPEOF(value) == STRSXP ){
++                value_size = LENGTH(value);
+ 			} else if( TYPEOF(value) == S4SXP && Rf_inherits( value, "Message") ){
+ 				value_size = 1 ; /* we will store the message payload */
+ 			} else if( TYPEOF(value) == VECSXP && allAreMessages( value ) ){
+@@ -1159,4 +1161,3 @@
+ }
+ 
+ } // namespace rprotobuf
+-
+Index: inst/unitTests/runit.golden.message.R
+===================================================================
+--- inst/unitTests/runit.golden.message.R	(revision 434)
++++ inst/unitTests/runit.golden.message.R	(working copy)
+@@ -60,4 +60,9 @@
+ 	test <- new(protobuf_unittest.TestAllTypes)
+ 	test$add("repeated_int32", c(1:5))
+ 	checkEquals(test$repeated_int32, c(1:5))
++
++        # Prior to RProtoBuf v0.2.5, this was not handled properly.
++        test.2 <- new(protobuf_unittest.TestAllTypes,
++                      repeated_string=c("foo", "bar"))
++        checkEquals(test.2$repeated_string, c("foo", "bar"))
+ }



More information about the Rprotobuf-commits mailing list