[Rprotobuf-commits] r466 - patches

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 9 04:05:19 CEST 2012


Author: edd
Date: 2012-08-09 04:05:19 +0200 (Thu, 09 Aug 2012)
New Revision: 466

Added:
   patches/patch_by_Murray_rprotobuf_r453.diff
   patches/patch_by_Murray_rprotobuf_r461.diff
Log:
added two more patches by Murray


Added: patches/patch_by_Murray_rprotobuf_r453.diff
===================================================================
--- patches/patch_by_Murray_rprotobuf_r453.diff	                        (rev 0)
+++ patches/patch_by_Murray_rprotobuf_r453.diff	2012-08-09 02:05:19 UTC (rev 466)
@@ -0,0 +1,45 @@
+Index: src/mutators.cpp
+===================================================================
+--- src/mutators.cpp	(revision 453)
++++ src/mutators.cpp	(working copy)
+@@ -367,7 +367,7 @@
+ 	
+ 	const Reflection * ref = message->GetReflection() ;
+     
+-	if( value == R_NilValue || LENGTH(value) == 0 ){
++	if( value == R_NilValue || (Rf_isVector(value) && LENGTH(value) == 0 )) {
+ 		ref->ClearField( message, field_desc ); 
+ 		return R_NilValue ;
+ 	}
+Index: inst/unitTests/runit.nested.R
+===================================================================
+--- inst/unitTests/runit.nested.R	(revision 0)
++++ inst/unitTests/runit.nested.R	(revision 0)
+@@ -0,0 +1,16 @@
++.setUp <- function(){
++    if( ! exists( "NestedOuter", "RProtoBuf:DescriptorPool" ) ) {
++        # None of the messages in unittest.proto is exactly right to tickle this bug.
++        unitest.proto.file <- system.file( "unitTests", "data", "nested.proto", package = "RProtoBuf" )
++        readProtoFiles(file = unitest.proto.file)
++    }
++}
++
++# RProtoBuf before v0.2.5 had a bug whereby uninitialized memory was read and used
++# to determine whether or not to update a nested message field in new() / update().
++test.nested <- function() {
++  for (i in 1:1000) {
++    q <- new(NestedOuter, b=new(NestedInner, x=1))
++    checkTrue(q$isInitialized())
++  }
++}
+Index: inst/unitTests/data/nested.proto
+===================================================================
+--- inst/unitTests/data/nested.proto	(revision 0)
++++ inst/unitTests/data/nested.proto	(revision 0)
+@@ -0,0 +1,6 @@
++message NestedInner {
++  required int32 x = 1;
++}
++message NestedOuter {
++  required NestedInner b = 1;
++}

Added: patches/patch_by_Murray_rprotobuf_r461.diff
===================================================================
--- patches/patch_by_Murray_rprotobuf_r461.diff	                        (rev 0)
+++ patches/patch_by_Murray_rprotobuf_r461.diff	2012-08-09 02:05:19 UTC (rev 466)
@@ -0,0 +1,64 @@
+Index: R/serialize.R
+===================================================================
+--- R/serialize.R	(revision 453)
++++ R/serialize.R	(working copy)
+@@ -7,7 +7,7 @@
+ setGeneric( "serialize" )
+ setMethod( "serialize", c( object = "Message" ) , 
+ 	function( object, connection, ascii = FALSE, refhook = NULL){
+-		
++                stopifnot(object$isInitialized())
+ 		iscon <- inherits(connection, "connection")
+ 		isnull <- is.null( connection )
+ 		
+@@ -42,4 +42,3 @@
+ 		}
+ 	}
+ )
+-
+Index: inst/unitTests/runit.serialize.R
+===================================================================
+--- inst/unitTests/runit.serialize.R	(revision 0)
++++ inst/unitTests/runit.serialize.R	(revision 0)
+@@ -0,0 +1,41 @@
++# Copyright 2012 Google Inc. All Rights Reserved.
++# Author: Murray Stokely
++#
++# This program is free software; you can redistribute it and/or
++# modify it under the terms of the GNU General Public License
++# as published by the Free Software Foundation; either version 2
++# of the License, or (at your option) any later version.
++#
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++# GNU General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with this program; if not, write to the Free Software
++# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
++
++
++# this is executed before each test function
++.setUp <- function(){
++	if( !exists("tutorial.Person", "RProtoBuf:DescriptorPool") ) {
++		unitest.proto.file <- system.file("proto", "addressbook.proto",
++                                                  package = "RProtoBuf" )
++		readProtoFiles(file = unitest.proto.file)
++	}
++}
++
++test.serialize <- function() {
++        person <- new(tutorial.Person)
++
++        checkTrue(!person$isInitialized())
++        checkException(serialize(person, NULL),
++                "Uninitialized object should fail to serialize.")
++        person$id <- 1
++        checkException(serialize(person, NULL),
++                "Uninitialized object should fail to serialize.")
++        person$name <- "Murray"
++
++        checkTrue(person$isInitialized())
++        checkTrue(length(serialize(person, NULL)) > 1)
++}



More information about the Rprotobuf-commits mailing list