[Rprotobuf-commits] r445 - in pkg: . src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon May 14 05:07:01 CEST 2012


Author: edd
Date: 2012-05-14 05:07:01 +0200 (Mon, 14 May 2012)
New Revision: 445

Modified:
   pkg/DESCRIPTION
   pkg/src/mutators.cpp
   pkg/src/wrapper_Message.cpp
Log:
upped version to 0.2.3.2 to mark difference
mutators and wrapper_Messages diff'ed from July version (which some patches
by Murray); will need to check once more
will have to check once more again


Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2012-05-14 02:56:27 UTC (rev 444)
+++ pkg/DESCRIPTION	2012-05-14 03:07:01 UTC (rev 445)
@@ -1,5 +1,5 @@
 Package: RProtoBuf
-Version: 0.2.3.1
+Version: 0.2.3.2
 Date: $Date$
 Author: Romain Francois <romain at r-enthusiasts.com> and Dirk Eddelbuettel <edd at debian.org>
 Maintainer: Romain and Dirk <RomainAndDirk at r-enthusiasts.com>

Modified: pkg/src/mutators.cpp
===================================================================
--- pkg/src/mutators.cpp	2012-05-14 02:56:27 UTC (rev 444)
+++ pkg/src/mutators.cpp	2012-05-14 03:07:01 UTC (rev 445)
@@ -132,52 +132,19 @@
 	return (uint32)0 ; // -Wall, should not happen since we only call this when we know it works
 }
 
-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] );
-			case REALSXP: 
-				return( (int64)REAL(x)[index] );
-			case LGLSXP:
-				return( (int64)LOGICAL(x)[index] );
-			case RAWSXP:
-				return( (int64)RAW(x)[index] ) ;
-			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] );
-			case REALSXP: 
-				return( (uint64)REAL(x)[index] );
-			case LGLSXP:
-				return( (uint64)LOGICAL(x)[index] );
-			case RAWSXP:
-				return( (uint64)RAW(x)[index] ) ;
-			default:
-				throwException( "cannot cast SEXP to uint64", "CastException" ) ; 
-		}
-#ifdef RCPP_HAS_INT64
+	switch( TYPEOF(x) ){
+		case INTSXP: 
+			return( (uint64)INTEGER(x)[index] );
+		case REALSXP: 
+			return( (uint64)REAL(x)[index] );
+		case LGLSXP:
+			return( (uint64)LOGICAL(x)[index] );
+		case RAWSXP:
+			return( (uint64)RAW(x)[index] ) ;
+		default:
+			throwException( "cannot cast SEXP to uint64", "CastException" ) ; 
 	}
-#endif
 	return (uint64)0 ; // -Wall, should not happen since we only call this when we know it works
 }
 
@@ -617,35 +584,23 @@
     		case TYPE_SINT64:
     		case TYPE_SFIXED64:
     			{
-#ifdef RCPP_HAS_INT64
-    				if( Rf_inherits( value, "int64") ){
-    					Rcpp::int64::LongVector<int64_t> data_int64(value) ;
-    					
-    					int i = 0 ;
-    					/* in any case, fill the values up to field_size */
-	    				for( ; i<field_size; i++){
-	    					ref->SetRepeatedInt64( message, field_desc, i, data_int64.get(i) ) ;
-	    				}
-	    				
-	    				/* then add some if needed */
-	    				if( value_size > field_size ){
-	    					for( ; i<value_size; i++){
-	    						ref->AddInt64( message, field_desc, data_int64.get(i) ) ;
-	    					}
-	    				}
-    				} else {
-#endif
-    					switch( TYPEOF( value ) ){ 
-    						case INTSXP:
-    						case REALSXP:
-    						case LGLSXP:
-    						case RAWSXP:	
-    							{
-    								int i = 0;
-                    	
-	    							/* in any case, fill the values up to field_size */
-	    							for( ; i<field_size; i++){
-	    								ref->SetRepeatedInt64( message, field_desc, i, GET_int64(value,i) ) ;
+    				switch( TYPEOF( value ) ){
+    					case INTSXP:
+    					case REALSXP:
+    					case LGLSXP:
+    					case RAWSXP:	
+    						{
+    							int i = 0;
+
+	    						/* in any case, fill the values up to field_size */
+	    						for( ; i<field_size; i++){
+	    							ref->SetRepeatedInt64( message, field_desc, i, GET_int64(value,i) ) ;
+	    						}
+	    						
+	    						/* then add some if needed */
+	    						if( value_size > field_size ){
+	    							for( ; i<value_size; i++){
+	    								ref->AddInt64( message, field_desc, GET_int64(value,i) ) ;
 	    							}
 	    						}
     							break ;
@@ -653,9 +608,7 @@
 
     					default: 
     						throwException( "Cannot convert to int64", "ConversionException" ) ; 
-#ifdef RCPP_HAS_INT64
     				}
-#endif
     				break ;
     			}
     			// }}}	
@@ -695,45 +648,30 @@
     		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) ;
-    					
-    					/* in any case, fill the values up to field_size */
-						for( ; i<field_size; i++){
-	    					ref->SetRepeatedUInt64( message, field_desc, i, data_uint64.get(i) ) ;
-	    				}
-	    				
-	    				/* then add some if needed */
-	    				if( value_size > field_size ){
-	    					for( ; i<value_size; i++){
-	    						ref->AddUInt64( message, field_desc, data_uint64.get(i) ) ;
-	    					}
-	    				}
-    					
-    				} else {
-#endif
-    					switch( TYPEOF( value ) ){
-	   						case INTSXP:
-    						case REALSXP:
-    						case LGLSXP:
-    						case RAWSXP:	
-    							{
-    								
-    								int i = 0;
-	    							/* in any case, fill the values up to field_size */
-									for( ; i<field_size; i++){
-	    								ref->SetRepeatedUInt64( message, field_desc, i, GET_uint64(value,i) ) ;
+    				switch( TYPEOF( value ) ){
+	   					case INTSXP:
+    					case REALSXP:
+    					case LGLSXP:
+    					case RAWSXP:	
+    						{
+    							
+    							int i = 0;
+	    						/* in any case, fill the values up to field_size */
+								for( ; i<field_size; i++){
+	    							ref->SetRepeatedUInt64( message, field_desc, i, GET_uint64(value,i) ) ;
+	    						}
+	    						
+	    						/* then add some if needed */
+	    						if( value_size > field_size ){
+	    							for( ; i<value_size; i++){
+	    								ref->AddUInt64( message, field_desc, GET_uint64(value,i) ) ;
 	    							}
 	    						}
     							break ;
     						}
     					default: 
     						throwException( "Cannot convert to int64", "ConversionException" ) ; 
-#ifdef RCPP_HAS_INT64
     				}
-#endif
     				break ;   
     			}
 			// }}}
@@ -1055,8 +993,10 @@
 
 			HANDLE_SINGLE_FIELD( CPPTYPE_INT32, Int32, GPB::int32) ;
 			HANDLE_SINGLE_FIELD( CPPTYPE_UINT32, UInt32, GPB::uint32) ;
+#ifdef RCPP_HAS_LONG_LONG_TYPES
 			HANDLE_SINGLE_FIELD( CPPTYPE_INT64, Int64, GPB::int64) ;
 			HANDLE_SINGLE_FIELD( CPPTYPE_UINT64, UInt64, GPB::uint64) ;
+#endif
 			HANDLE_SINGLE_FIELD( CPPTYPE_DOUBLE, Double, double) ;
 			HANDLE_SINGLE_FIELD( CPPTYPE_FLOAT, Float, float) ;
 			HANDLE_SINGLE_FIELD( CPPTYPE_BOOL, Bool, bool) ;

Modified: pkg/src/wrapper_Message.cpp
===================================================================
--- pkg/src/wrapper_Message.cpp	2012-05-14 02:56:27 UTC (rev 444)
+++ pkg/src/wrapper_Message.cpp	2012-05-14 03:07:01 UTC (rev 445)
@@ -713,29 +713,17 @@
     			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++){
-    					        ref->AddInt64( message, field_desc, data.get(i) ) ;
-	    				   	}
-	    				   	
-    					} else {
-#endif
-    					    switch( TYPEOF( values ) ){
-    					   	   case INTSXP:
-    					   	   case REALSXP:
-    					   	   case LGLSXP:
-    					   	   case RAWSXP:	
-    					   	       for( int i=0; i<value_size; i++){
-    					   	           ref->AddInt64( message, field_desc, GET_int64(values,i) ) ;
-	    				   	       }
-	    				   	   default: 
-    					   	   	throwException( "Cannot convert to int64", "ConversionException" ) ; 
-    					   }
-#ifdef RCPP_HAS_INT64
+    					switch( TYPEOF( values ) ){
+    						case INTSXP:
+    						case REALSXP:
+    						case LGLSXP:
+    						case RAWSXP:	
+    							for( int i=0; i<value_size; i++){
+	    							ref->AddInt64( message, field_desc, GET_int64(values,i) ) ;
+	    						}
+	    					default: 
+    							throwException( "Cannot convert to int64", "ConversionException" ) ; 
     					}
-#endif
     					break ;
     				}
     				// }}}	
@@ -766,32 +754,20 @@
     			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++){
-	    				    	ref->AddUInt64( message, field_desc, data.get(i) ) ;
-	    				    }
-	    				    
-    					} else {
-#endif
-    					    switch( TYPEOF( values ) ){
-	   					    	case INTSXP:
-    					    	case REALSXP:
-    					    	case LGLSXP:
-    					    	case RAWSXP:	
-    					    		{
-    					    			for( int i=0; i<value_size; i++){
-	    				    				ref->AddUInt64( message, field_desc, GET_uint64(values,i) ) ;
-	    				    			}
-	    				    			break ;
-    					    		}
-    					    	default: 
-    					    		throwException( "Cannot convert to int64", "ConversionException" ) ; 
-    					    }
-#ifdef RCPP_HAS_INT64
+    					switch( TYPEOF( values ) ){
+	   						case INTSXP:
+    						case REALSXP:
+    						case LGLSXP:
+    						case RAWSXP:	
+    							{
+    								for( int i=0; i<value_size; i++){
+	    								ref->AddUInt64( message, field_desc, GET_uint64(values,i) ) ;
+	    							}
+	    							break ;
+    							}
+    						default: 
+    							throwException( "Cannot convert to int64", "ConversionException" ) ; 
     					}
-#endif
     					break ;   
     				}
 				// }}}
@@ -1002,37 +978,8 @@
 					}
 					return res; 
 				}
-		case TYPE_ENUM:
-		        {
-		           Rcpp::IntegerVector res(n) ;
-	    			for( int i=0; i<n; i++){
-						res[i] = (int)ref->GetRepeatedEnum( *message, field_desc, index[i] )->number() ;
-					}
-					return res;
-		        }
-#ifdef RCPP_HAS_INT64
-		case TYPE_INT64:
-    		case TYPE_SINT64:
-    		case TYPE_SFIXED64:
-    		    {
-    		        Rcpp::int64::LongVector<int64_t> res(n) ;
-    		        for( int i=0; i<n; i++){
-    		          res.set(i, ref->GetRepeatedInt64( *message, field_desc, index[i] ) ) ;  
-    		        }
-    		        return res ;
-    		    }
-		case TYPE_FIXED64:
-	    	case TYPE_UINT64:
-	    	    {
-	    	        Rcpp::int64::LongVector<uint64_t> res(n) ;
-    		        for( int i=0; i<n; i++){
-    		          res.set(i, ref->GetRepeatedUInt64( *message, field_desc, index[i] ) ) ;  
-    		        }
-    		        return res ;
-	    	    }
-#endif			
-		case TYPE_DOUBLE:
-		case TYPE_FLOAT:
+			case TYPE_DOUBLE:
+		    case TYPE_FLOAT:
 				{
 					Rcpp::NumericVector res(n) ;
 					for( int i=0; i<n; i++){
@@ -1041,7 +988,7 @@
 					}
 					return res; 
 				}
-		case TYPE_BOOL:
+			case TYPE_BOOL:
 				{
 					Rcpp::LogicalVector res(n) ;
 	    			for( int i=0; i<n; i++){
@@ -1050,7 +997,7 @@
 					}
 					return res; 
 				}
-		case TYPE_STRING:
+			case TYPE_STRING:
 	    		{
 	    			const GPB::Reflection* ref = message->GetReflection() ; 
 	    			Rcpp::CharacterVector res(n) ;
@@ -1118,8 +1065,7 @@
 						}
 						break ;
 					}
-#ifdef RCPP_HAS_INT64
-		        case TYPE_INT64:
+				case TYPE_INT64:
     			case TYPE_SINT64:
     			case TYPE_SFIXED64:
 					{	
@@ -1130,7 +1076,6 @@
 						}
 						break ;
 					}
-#endif
 	    		case TYPE_UINT32:
 	    		case TYPE_FIXED32:
 	    			{
@@ -1141,7 +1086,6 @@
 						}
 						break ;
 	    			}
-#ifdef RCPP_HAS_INT64
 	    		case TYPE_UINT64:
 	    		case TYPE_FIXED64:
 	    			{
@@ -1152,7 +1096,6 @@
 						}
 						break ;
 					}
-#endif
 				case TYPE_DOUBLE:
 		    		{
 		    			for( int i=0; i<n; i++){



More information about the Rprotobuf-commits mailing list