[Rprotobuf-commits] r438 - pkg/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon May 14 03:04:49 CEST 2012
Author: edd
Date: 2012-05-14 03:04:48 +0200 (Mon, 14 May 2012)
New Revision: 438
Modified:
pkg/src/mutators.cpp
pkg/src/streams.cpp
pkg/src/wrapper_Message.cpp
Log:
committing some older pending changes which ifdef for int64
Modified: pkg/src/mutators.cpp
===================================================================
--- pkg/src/mutators.cpp 2012-04-07 18:02:22 UTC (rev 437)
+++ pkg/src/mutators.cpp 2012-05-14 01:04:48 UTC (rev 438)
@@ -118,9 +118,11 @@
int64 GET_int64( SEXP x, int index ){
+#ifdef RCPP_HAS_INT64
if( Rf_inherits(x, "int64" ) ){
return Rcpp::int64::LongVector<int64_t>(x).get(index) ;
} else {
+#endif
switch( TYPEOF(x) ){
case INTSXP:
return( (int64)INTEGER(x)[index] );
@@ -133,16 +135,20 @@
default:
throwException( "cannot cast SEXP to int64", "CastException" ) ;
}
+#ifdef RCPP_HAS_INT64
}
+#endif
return (int64)0 ; // -Wall, should not happen since we only call this when we know it works
}
uint64 GET_uint64( SEXP x, int index ){
+#ifdef RCPP_HAS_INT64
if( Rf_inherits( x, "uint64" ) ){
return Rcpp::int64::LongVector<uint64_t>(x).get(index) ;
} else {
+#endif
switch( TYPEOF(x) ){
case INTSXP:
return( (uint64)INTEGER(x)[index] );
@@ -155,7 +161,9 @@
default:
throwException( "cannot cast SEXP to uint64", "CastException" ) ;
}
+#ifdef RCPP_HAS_INT64
}
+#endif
return (uint64)0 ; // -Wall, should not happen since we only call this when we know it works
}
@@ -595,6 +603,7 @@
case TYPE_SINT64:
case TYPE_SFIXED64:
{
+#ifdef RCPP_HAS_INT64
if( Rf_inherits( value, "int64") ){
Rcpp::int64::LongVector<int64_t> data_int64(value) ;
@@ -611,6 +620,7 @@
}
}
} else {
+#endif
switch( TYPEOF( value ) ){
case INTSXP:
case REALSXP:
@@ -636,7 +646,9 @@
default:
throwException( "Cannot convert to int64", "ConversionException" ) ;
}
+#ifdef RCPP_HAS_INT64
}
+#endif
break ;
}
// }}}
@@ -676,6 +688,7 @@
case TYPE_UINT64:
case TYPE_FIXED64:
{
+#ifdef RCPP_HAS_INT64
if( Rf_inherits( value, "uint64" ) ){
int i = 0 ;
Rcpp::int64::LongVector<uint64_t> data_uint64(value) ;
@@ -693,6 +706,7 @@
}
} else {
+#endif
switch( TYPEOF( value ) ){
case INTSXP:
case REALSXP:
@@ -717,7 +731,9 @@
default:
throwException( "Cannot convert to int64", "ConversionException" ) ;
}
+#ifdef RCPP_HAS_INT64
}
+#endif
break ;
}
// }}}
Modified: pkg/src/streams.cpp
===================================================================
--- pkg/src/streams.cpp 2012-04-07 18:02:22 UTC (rev 437)
+++ pkg/src/streams.cpp 2012-05-14 01:04:48 UTC (rev 438)
@@ -189,6 +189,7 @@
return Rf_ScalarInteger( res ) ;
}
+#ifdef RCPP_HAS_INT64
SEXP ZeroCopyInputStream_ReadLittleEndian64( SEXP xp){
GPB::io::CodedInputStream* coded_stream = GET_CIS(xp) ;
uint64 res = 0 ;
@@ -202,6 +203,7 @@
if( !coded_stream->ReadVarint64( &res ) ) Rf_error( "error reading varint64" ) ;
return Rcpp::int64::LongVector<uint64_t>( res ) ;
}
+#endif
// }}}
// {{{ Write*** functions using CodedOuputStream
Modified: pkg/src/wrapper_Message.cpp
===================================================================
--- pkg/src/wrapper_Message.cpp 2012-04-07 18:02:22 UTC (rev 437)
+++ pkg/src/wrapper_Message.cpp 2012-05-14 01:04:48 UTC (rev 438)
@@ -193,7 +193,7 @@
return( message->GetDescriptor() ) ;
}
-RCPP_XP_METHOD_0( METHOD(as_character) , GPB::Message, DebugString) ;
+RCPP_XP_METHOD_0( METHOD(as_character) , GPB::Message, DebugString)
RCPP_XP_METHOD_0( METHOD(bytesize), GPB::Message, ByteSize )
RCPP_FUNCTION_2( int, METHOD(field_size), Rcpp::XPtr<GPB::Message> message, SEXP field ){
@@ -686,6 +686,7 @@
case TYPE_SINT64:
case TYPE_SFIXED64:
{
+#ifdef RCPP_HAS_INT64
if( Rf_inherits( values, "int64" ) ){
Rcpp::int64::LongVector<int64_t> data(values) ;
for( int i=0; i<value_size; i++){
@@ -693,6 +694,7 @@
}
} else {
+#endif
switch( TYPEOF( values ) ){
case INTSXP:
case REALSXP:
@@ -704,7 +706,9 @@
default:
throwException( "Cannot convert to int64", "ConversionException" ) ;
}
+#ifdef RCPP_HAS_INT64
}
+#endif
break ;
}
// }}}
@@ -735,6 +739,7 @@
case TYPE_UINT64:
case TYPE_FIXED64:
{
+#ifdef RCPP_HAS_INT64
if(Rf_inherits(values, "uint64" )){
Rcpp::int64::LongVector<uint64_t> data(values) ;
for( int i=0; i<value_size; i++){
@@ -742,6 +747,7 @@
}
} else {
+#endif
switch( TYPEOF( values ) ){
case INTSXP:
case REALSXP:
@@ -756,7 +762,9 @@
default:
throwException( "Cannot convert to int64", "ConversionException" ) ;
}
+#ifdef RCPP_HAS_INT64
}
+#endif
break ;
}
// }}}
@@ -969,7 +977,7 @@
}
return res;
}
- case TYPE_ENUM:
+ case TYPE_ENUM:
{
Rcpp::IntegerVector res(n) ;
for( int i=0; i<n; i++){
@@ -977,7 +985,8 @@
}
return res;
}
- case TYPE_INT64:
+#ifdef RCPP_HAS_INT64
+ case TYPE_INT64:
case TYPE_SINT64:
case TYPE_SFIXED64:
{
@@ -987,7 +996,7 @@
}
return res ;
}
- case TYPE_FIXED64:
+ case TYPE_FIXED64:
case TYPE_UINT64:
{
Rcpp::int64::LongVector<uint64_t> res(n) ;
@@ -996,9 +1005,9 @@
}
return res ;
}
-
- case TYPE_DOUBLE:
- case TYPE_FLOAT:
+#endif
+ case TYPE_DOUBLE:
+ case TYPE_FLOAT:
{
Rcpp::NumericVector res(n) ;
for( int i=0; i<n; i++){
@@ -1007,7 +1016,7 @@
}
return res;
}
- case TYPE_BOOL:
+ case TYPE_BOOL:
{
Rcpp::LogicalVector res(n) ;
for( int i=0; i<n; i++){
@@ -1016,7 +1025,7 @@
}
return res;
}
- case TYPE_STRING:
+ case TYPE_STRING:
{
const GPB::Reflection* ref = message->GetReflection() ;
Rcpp::CharacterVector res(n) ;
@@ -1084,7 +1093,8 @@
}
break ;
}
- case TYPE_INT64:
+#ifdef RCPP_HAS_INT64
+ case TYPE_INT64:
case TYPE_SINT64:
case TYPE_SFIXED64:
{
@@ -1104,6 +1114,7 @@
}
break ;
}
+#endif
case TYPE_UINT32:
case TYPE_FIXED32:
{
@@ -1114,6 +1125,7 @@
}
break ;
}
+#ifdef RCPP_HAS_INT64
case TYPE_UINT64:
case TYPE_FIXED64:
{
@@ -1133,6 +1145,7 @@
}
break ;
}
+#endif
case TYPE_DOUBLE:
{
for( int i=0; i<n; i++){
More information about the Rprotobuf-commits
mailing list