[Rprotobuf-commits] r669 - pkg/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Dec 31 12:00:06 CET 2013
Author: murray
Date: 2013-12-31 12:00:05 +0100 (Tue, 31 Dec 2013)
New Revision: 669
Modified:
pkg/src/extractors.cpp
pkg/src/mutators.cpp
Log:
Remove some unreachable/dead code tokens found by Flexelint. Also
Flexelint highglights how this code doesn't currently work with long
vectors due to the use of ints for indexing elements instead of longs.
Add some comments.
Modified: pkg/src/extractors.cpp
===================================================================
--- pkg/src/extractors.cpp 2013-12-31 08:04:55 UTC (rev 668)
+++ pkg/src/extractors.cpp 2013-12-31 11:00:05 UTC (rev 669)
@@ -92,12 +92,12 @@
case TYPE: \
return Rcpp::wrap(RepeatedFieldImporter<DATATYPE>(ref, *message, fieldDesc));
- HANDLE_REPEATED_FIELD(CPPTYPE_INT32, GPB::int32);
- HANDLE_REPEATED_FIELD(CPPTYPE_DOUBLE, double);
- HANDLE_REPEATED_FIELD(CPPTYPE_FLOAT, float);
- HANDLE_REPEATED_FIELD(CPPTYPE_BOOL, bool);
- HANDLE_REPEATED_FIELD(CPPTYPE_ENUM, enum_field);
- HANDLE_REPEATED_FIELD(CPPTYPE_MESSAGE, message_field);
+ HANDLE_REPEATED_FIELD(CPPTYPE_INT32, GPB::int32)
+ HANDLE_REPEATED_FIELD(CPPTYPE_DOUBLE, double)
+ HANDLE_REPEATED_FIELD(CPPTYPE_FLOAT, float)
+ HANDLE_REPEATED_FIELD(CPPTYPE_BOOL, bool)
+ HANDLE_REPEATED_FIELD(CPPTYPE_ENUM, enum_field)
+ HANDLE_REPEATED_FIELD(CPPTYPE_MESSAGE, message_field)
// 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
@@ -149,10 +149,10 @@
case CPPTYPE: \
return Rcpp::wrap(ref->Get##SUFFIX(*message, fieldDesc));
- HANDLE_SINGLE_FIELD(CPPTYPE_INT32, Int32);
- HANDLE_SINGLE_FIELD(CPPTYPE_DOUBLE, Double);
- HANDLE_SINGLE_FIELD(CPPTYPE_FLOAT, Float);
- HANDLE_SINGLE_FIELD(CPPTYPE_BOOL, Bool);
+ HANDLE_SINGLE_FIELD(CPPTYPE_INT32, Int32)
+ 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
@@ -182,7 +182,6 @@
case CPPTYPE_MESSAGE:
return S4_Message(CLONE(&ref->GetMessage(*message, fieldDesc)));
- break;
default:
Rcpp::stop("Unsupported type");
Modified: pkg/src/mutators.cpp
===================================================================
--- pkg/src/mutators.cpp 2013-12-31 08:04:55 UTC (rev 668)
+++ pkg/src/mutators.cpp 2013-12-31 11:00:05 UTC (rev 669)
@@ -104,6 +104,8 @@
return ret;
}
+ // TODO(mstokely): not long vector clean. int index should be R_xlen_t
+ // Add test illustrating the problem by using size(repeated_field)<-bignum
int32 GET_int32(SEXP x, int index) {
switch (TYPEOF(x)) {
case INTSXP:
@@ -292,7 +294,7 @@
case REALSXP:
case LGLSXP:
case RAWSXP: {
- int nenums = enum_desc->value_count();
+ int nenums = enum_desc->value_count(); // Guaranteed to be > 0.
std::vector<int> possibles(nenums);
for (int i = 0; i < nenums; i++) {
possibles[i] = enum_desc->value(i)->number();
@@ -528,8 +530,8 @@
break; \
}
- HANDLE_SINGLE_FIELD(CPPTYPE_DOUBLE, Double, double);
- HANDLE_SINGLE_FIELD(CPPTYPE_FLOAT, Float, float);
+ HANDLE_SINGLE_FIELD(CPPTYPE_DOUBLE, Double, double)
+ HANDLE_SINGLE_FIELD(CPPTYPE_FLOAT, Float, float)
case CPPTYPE_BOOL: {
// TODO(mstokely): Rcpp should handle this!
if ((TYPEOF(value) == LGLSXP) && (LOGICAL(value)[0] == NA_LOGICAL)) {
More information about the Rprotobuf-commits
mailing list