[Rprotobuf-commits] r626 - in pkg: . src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Dec 28 20:08:35 CET 2013
Author: murray
Date: 2013-12-28 20:08:34 +0100 (Sat, 28 Dec 2013)
New Revision: 626
Modified:
pkg/ChangeLog
pkg/src/extractors.cpp
Log:
Handle large uint32s properly by casting to double before calling
Rcpp::wrap since wrap is broken for uint32s still. With this change,
we correctly get a large uint32 instead of -1 :
foo$large_uint32
[1] 4294967295
Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog 2013-12-28 04:45:51 UTC (rev 625)
+++ pkg/ChangeLog 2013-12-28 19:08:34 UTC (rev 626)
@@ -1,3 +1,11 @@
+2013-12-28 Murray Stokely <mstokely at google.com>
+
+ * src/extractors.cpp (rprotobuf): Correct handling of uint32 for
+ single values greater than 2^31 by returning as R numeric types
+ to avoid losing precision since R doesn't have unsigned int
+ types but C++ does. Works around an Rcpp bug
+ https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1360&group_id=155&atid=637
+
2013-12-27 Murray Stokely <mstokely at google.com>
* src/mutators.cpp: Refactor setMessageField into four separate
Modified: pkg/src/extractors.cpp
===================================================================
--- pkg/src/extractors.cpp 2013-12-28 04:45:51 UTC (rev 625)
+++ pkg/src/extractors.cpp 2013-12-28 19:08:34 UTC (rev 626)
@@ -97,6 +97,8 @@
return Rcpp::wrap( RepeatedFieldImporter<DATATYPE>(ref, *message, fieldDesc) ) ; \
HANDLE_REPEATED_FIELD(CPPTYPE_INT32, GPB::int32) ;
+ // TODO(mstokely): Rcpp doesn't handle uint32 properly as of 2013/12
+ // See https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1360&group_id=155&atid=637
HANDLE_REPEATED_FIELD(CPPTYPE_UINT32, GPB::uint32) ;
HANDLE_REPEATED_FIELD(CPPTYPE_DOUBLE, double) ;
HANDLE_REPEATED_FIELD(CPPTYPE_FLOAT, float) ;
@@ -155,10 +157,13 @@
return Rcpp::wrap( ref->Get##SUFFIX(*message, fieldDesc ) ) ;
HANDLE_SINGLE_FIELD( CPPTYPE_INT32, Int32 );
- HANDLE_SINGLE_FIELD( CPPTYPE_UINT32, UInt32 );
HANDLE_SINGLE_FIELD( CPPTYPE_DOUBLE, Double );
HANDLE_SINGLE_FIELD( CPPTYPE_FLOAT, Float );
HANDLE_SINGLE_FIELD( CPPTYPE_BOOL, Bool );
+ // TODO(mstokely): Rcpp doesn't handle uint32 properly as of 2013/12
+ // See https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1360&group_id=155&atid=637
+ case CPPTYPE_UINT32:
+ return Rcpp::wrap( double(ref->GetUInt32(*message, fieldDesc)));
#ifdef RCPP_HAS_LONG_LONG_TYPES
// Handle these types separately since Rcpp::wrap doesn't
// do the right thing.
More information about the Rprotobuf-commits
mailing list