[Rprotobuf-commits] r628 - pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 30 18:20:59 CET 2013


Author: murray
Date: 2013-12-30 18:20:59 +0100 (Mon, 30 Dec 2013)
New Revision: 628

Modified:
   pkg/src/mutators.cpp
Log:
Correct a few more parts of the code path that coerced uint32s to
int32 and thus truncated precision.



Modified: pkg/src/mutators.cpp
===================================================================
--- pkg/src/mutators.cpp	2013-12-29 23:17:34 UTC (rev 627)
+++ pkg/src/mutators.cpp	2013-12-30 17:20:59 UTC (rev 628)
@@ -592,7 +592,9 @@
 							   Int32FromString<GPB::uint32>(uint32str));
 				break ;
 			} else {
-				ref->SetUInt32( message, field_desc, Rcpp::as<GPB::uint32>(value));
+				// Rcpp::as is broken for uint32 types, so we just get Rcpp
+				// to give us a valid double, 
+				ref->SetUInt32( message, field_desc, Rcpp::as<double>(value));
 				break;
 			}
 		}
@@ -855,14 +857,14 @@
 					/* in any case, fill the values up to field_size */
 					for( ; i<field_size; i++){
 						ref->SetRepeatedUInt32( message, field_desc, i,
-												GET_int32(value,i) ) ;
+												GET_uint32(value,i) ) ;
 					}
 	    						
 					/* then add some if needed */
 					if( value_size > field_size ){
 						for( ; i<value_size; i++){
 							ref->AddUInt32( message, field_desc,
-											GET_int32(value,i) ) ;
+											GET_uint32(value,i) ) ;
 						}
 					}
 					break ;



More information about the Rprotobuf-commits mailing list