[Rprotobuf-commits] r324 - in pkg: R src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon May 10 15:33:08 CEST 2010


Author: romain
Date: 2010-05-10 15:33:07 +0200 (Mon, 10 May 2010)
New Revision: 324

Removed:
   pkg/src/add.cpp
   pkg/src/completion.cpp
   pkg/src/fileDescriptor.cpp
   pkg/src/identical.cpp
   pkg/src/merge.cpp
   pkg/src/methods.cpp
   pkg/src/name.cpp
   pkg/src/read.cpp
   pkg/src/set.cpp
   pkg/src/swap.cpp
Modified:
   pkg/R/00classes.R
   pkg/R/completion.R
   pkg/R/descriptor.R
   pkg/R/merge.R
   pkg/R/read.R
   pkg/R/set.R
   pkg/R/swap.R
   pkg/R/with.R
   pkg/R/wrapper_MethodDescriptor.R
   pkg/src/RSourceTree.cpp
   pkg/src/exceptions.cpp
   pkg/src/extractors.cpp
   pkg/src/rprotobuf.cpp
   pkg/src/rprotobuf.h
   pkg/src/wrapper_Descriptor.cpp
   pkg/src/wrapper_EnumDescriptor.cpp
   pkg/src/wrapper_FieldDescriptor.cpp
   pkg/src/wrapper_FileDescriptor.cpp
   pkg/src/wrapper_Message.cpp
   pkg/src/wrapper_MethodDescriptor.cpp
   pkg/src/wrapper_ServiceDescriptor.cpp
Log:
move more code to wrapper_* files

Modified: pkg/R/00classes.R
===================================================================
--- pkg/R/00classes.R	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/R/00classes.R	2010-05-10 13:33:07 UTC (rev 324)
@@ -260,7 +260,7 @@
 		"method_count" = function() method_count(x), 
 		"method" = function(...) method(x, ... ), 
 		
-		.Call( "get_service_method", x at pointer, name, PACKAGE = "RProtoBuf" )
+		.Call( "ServiceDescriptor__method", x at pointer, name, PACKAGE = "RProtoBuf" )
 		)
 } )
 
@@ -386,7 +386,7 @@
 		warning( "`j` is ignored" )
 	}
 	if( is.character( i ) || is.numeric( i ) ){
-		.Call( "get_service_method", x at pointer, name, PACKAGE = "RProtoBuf" )
+		.Call( "ServiceDescriptor__method", x at pointer, name, PACKAGE = "RProtoBuf" )
 	} else{
 		stop( "wrong type, `i` should be a character or a number" )
 	}
@@ -470,27 +470,27 @@
 })
 setMethod( "name", c( object = "Descriptor" ) , 
 function(object, full = FALSE){
-	.Call( "name_descriptor", object at pointer, full, PACKAGE = "RProtoBuf" )
+	.Call( "Descriptor__name", object at pointer, full, PACKAGE = "RProtoBuf" )
 }) 
 setMethod( "name", c( object = "FieldDescriptor" ) , 
 function(object, full = FALSE){
-	.Call( "name_descriptor", object at pointer, full, PACKAGE = "RProtoBuf" )
+	.Call( "FieldDescriptor__name", object at pointer, full, PACKAGE = "RProtoBuf" )
 })
 setMethod( "name", c( object = "EnumDescriptor" ) , 
 function(object, full = FALSE){
-	.Call( "name_enum_descriptor", object at pointer, full, PACKAGE = "RProtoBuf" )
+	.Call( "EnumDescriptor__name", object at pointer, full, PACKAGE = "RProtoBuf" )
 })
 setMethod( "name", c( object = "ServiceDescriptor" ) , 
 function(object, full = FALSE){
-	.Call( "name_service_descriptor", object at pointer, full, PACKAGE = "RProtoBuf" )
+	.Call( "ServiceDescriptor__name", object at pointer, full, PACKAGE = "RProtoBuf" )
 })
 setMethod( "name", c( object = "MethodDescriptor" ) , 
 function(object, full = FALSE){
-	.Call( "name_method_descriptor", object at pointer, full, PACKAGE = "RProtoBuf" )
+	.Call( "MethodDescriptor__name", object at pointer, full, PACKAGE = "RProtoBuf" )
 })
 setMethod( "name", c( object = "FileDescriptor" ) , 
 function(object, full = FALSE){
-	filename <- .Call( "name_file_descriptor", object at pointer, PACKAGE = "RProtoBuf" )
+	filename <- .Call( "FileDescriptor__name", object at pointer, PACKAGE = "RProtoBuf" )
 	if( full ) filename else basename( filename )
 })
 # }}}

Modified: pkg/R/completion.R
===================================================================
--- pkg/R/completion.R	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/R/completion.R	2010-05-10 13:33:07 UTC (rev 324)
@@ -15,7 +15,7 @@
 .DollarNames.Message <- function(x, pattern = "" ){
 	
 	names <- c( 
-		.Call( "getMessageFieldNames", x at pointer, PACKAGE = "RProtoBuf" ) ,
+		.Call( "Message__fieldNames", x at pointer, PACKAGE = "RProtoBuf" ) ,
 		"has(", "clone()", "clone(", "isInitialized()", "serialize(", 
 		"clear()", "clear(", "size(", "bytesize()", 
 		"swap(", "str()", "as.character()", "update(", "as.list()", 
@@ -28,7 +28,7 @@
 .DollarNames.Descriptor <- function(x, pattern = "" ){
 	
 	names <- c( 
-		.Call( "getDescriptorMemberNames", x at pointer, PACKAGE = "RProtoBuf" ), 
+		.Call( "Descriptor__getMemberNames", x at pointer, PACKAGE = "RProtoBuf" ), 
 		"new(", "read(", "fileDescriptor()", "name(", "fileDescriptor()", 
 		"containing_type()", "field_count()", "nested_type_count()", "enum_type_count", 
 		"field(", "nested_type(", "enum_type(" )

Modified: pkg/R/descriptor.R
===================================================================
--- pkg/R/descriptor.R	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/R/descriptor.R	2010-05-10 13:33:07 UTC (rev 324)
@@ -10,21 +10,21 @@
 	standardGeneric( "fileDescriptor" )
 } )
 setMethod( "fileDescriptor", "Message", function(object, ...){
-	.Call( "get_message_file_descriptor", object at pointer, PACKAGE = "RProtoBuf" )
+	.Call( "Message__fileDescriptor", object at pointer, PACKAGE = "RProtoBuf" )
 } )
 setMethod( "fileDescriptor", "Descriptor", function(object, ...){
-	.Call( "get_descriptor_file_descriptor", object at pointer, PACKAGE = "RProtoBuf" )
+	.Call( "Descriptor__fileDescriptor", object at pointer, PACKAGE = "RProtoBuf" )
 } )
 setMethod( "fileDescriptor", "EnumDescriptor", function(object, ...){
-	.Call( "get_enum_file_descriptor", object at pointer, PACKAGE = "RProtoBuf" )
+	.Call( "EnumDescriptor__fileDescriptor", object at pointer, PACKAGE = "RProtoBuf" )
 } )
 setMethod( "fileDescriptor", "FieldDescriptor", function(object, ...){
-	.Call( "get_field_file_descriptor", object at pointer, PACKAGE = "RProtoBuf" )
+	.Call( "FieldDescriptor__fileDescriptor", object at pointer, PACKAGE = "RProtoBuf" )
 } )
 setMethod( "fileDescriptor", "ServiceDescriptor", function(object, ...){
-	.Call( "get_service_file_descriptor", object at pointer, PACKAGE = "RProtoBuf" )
+	.Call( "ServiceDescriptor__fileDescriptor", object at pointer, PACKAGE = "RProtoBuf" )
 } )
 setMethod( "fileDescriptor", "MethodDescriptor", function(object, ...){
-	.Call( "get_method_file_descriptor", object at pointer, PACKAGE = "RProtoBuf" )
+	.Call( "MethodDescriptor__fileDescriptor", object at pointer, PACKAGE = "RProtoBuf" )
 } )
 

Modified: pkg/R/merge.R
===================================================================
--- pkg/R/merge.R	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/R/merge.R	2010-05-10 13:33:07 UTC (rev 324)
@@ -8,7 +8,7 @@
 				"IncompatibleType" )
 		}
 		
-		message <- .Call( "merge_message", x at pointer, y at pointer )
+		message <- .Call( "Message__merge", x at pointer, y at pointer )
 		message
 } )
 

Modified: pkg/R/read.R
===================================================================
--- pkg/R/read.R	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/R/read.R	2010-05-10 13:33:07 UTC (rev 324)
@@ -6,11 +6,11 @@
 setMethod( "read", c( descriptor = "Descriptor" , input = "character" ), 
 function(descriptor, input ){
 	file <- tools:::file_path_as_absolute( input )
-	.Call( "readMessageFromFile", descriptor at pointer, file, PACKAGE = "RProtoBuf" ) 
+	.Call( "Descriptor__readMessageFromFile", descriptor at pointer, file, PACKAGE = "RProtoBuf" ) 
 } )
 
 setMethod( "read", c( descriptor = "Descriptor", input = "raw" ), function(descriptor, input ){
-	.Call( "readMessageFromRawVector", descriptor at pointer, input, PACKAGE="RProtoBuf" )
+	.Call( "Descriptor__readMessageFromRawVector", descriptor at pointer, input, PACKAGE="RProtoBuf" )
 } )
 
 setMethod( "read", c( descriptor = "Descriptor" ), 
@@ -21,7 +21,7 @@
 	sc <- summary( input )
 	wasopen <- identical( sc[["opened"]], "opened" )
 	if( !wasopen ) open( input )
-	message <- .Call( "readMessageFromConnection", descriptor at pointer, input, PACKAGE = "RProtoBuf" )
+	message <- .Call( "Descriptor__readMessageFromConnection", descriptor at pointer, input, PACKAGE = "RProtoBuf" )
 	if( !wasopen ) close( input )
 	message
 } )

Modified: pkg/R/set.R
===================================================================
--- pkg/R/set.R	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/R/set.R	2010-05-10 13:33:07 UTC (rev 324)
@@ -22,7 +22,7 @@
 		stop( sprintf( "index should only contain values between 1 and %d", fsize )  ) 
 	}
 	
-	.Call( "set_field_values", object at pointer, 
+	.Call( "Message__set_field_values", object at pointer, 
 		field, index - 1L , values, 
 		PACKAGE = "RProtoBuf" )
 		
@@ -42,7 +42,7 @@
 	if( any( index > fsize ) || any( index < 1) ){
 		stop( sprintf( "index should only contain values between 1 and %d", fsize )  ) 
 	}
-	.Call( "get_field_values", object at pointer, 
+	.Call( "Message__get_field_values", object at pointer, 
 		field, index - 1L , PACKAGE = "RProtoBuf" )
 } )
 

Modified: pkg/R/swap.R
===================================================================
--- pkg/R/swap.R	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/R/swap.R	2010-05-10 13:33:07 UTC (rev 324)
@@ -8,7 +8,7 @@
 	if( length(left) != length(right) ){
 		stop( "left and right should have the same length" )
 	}
-	.Call( "message_swap_fields", object at pointer, field, left, right, 
+	.Call( "Message__swap_fields", object at pointer, field, left, right, 
 		PACKAGE = "RProtoBuf" ) 
 	invisible( object )
 } )

Modified: pkg/R/with.R
===================================================================
--- pkg/R/with.R	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/R/with.R	2010-05-10 13:33:07 UTC (rev 324)
@@ -3,7 +3,7 @@
 generateActiveBindings <- function(data){
 	env <- new.env( parent = environment() )
 	xp <- data at pointer
-	names <- .Call( "getMessageFieldNames", xp, PACKAGE = "RProtoBuf" ) 
+	names <- .Call( "Message__fieldNames", xp, PACKAGE = "RProtoBuf" ) 
 	
 	if( !is.null(names) && length(names) ){
 		lapply( names, function(x ){

Modified: pkg/R/wrapper_MethodDescriptor.R
===================================================================
--- pkg/R/wrapper_MethodDescriptor.R	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/R/wrapper_MethodDescriptor.R	2010-05-10 13:33:07 UTC (rev 324)
@@ -7,10 +7,10 @@
 } )
 
 setMethod( "input_type", "MethodDescriptor", function(object){
-	.Call("get_method_input_type", object at pointer, PACKAGE = "RProtoBuf" )
+	.Call("MethodDescriptor__input_type", object at pointer, PACKAGE = "RProtoBuf" )
 } )
 
 setMethod( "output_type", "MethodDescriptor", function(object){
-	.Call("get_method_output_type", object at pointer, PACKAGE = "RProtoBuf" )
+	.Call("MethodDescriptor__output_type", object at pointer, PACKAGE = "RProtoBuf" )
 } )
 

Modified: pkg/src/RSourceTree.cpp
===================================================================
--- pkg/src/RSourceTree.cpp	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/src/RSourceTree.cpp	2010-05-10 13:33:07 UTC (rev 324)
@@ -3,9 +3,7 @@
 
 namespace rprotobuf {
 
-	RSourceTree::RSourceTree(){
-		std::set<std::string> directories ;
-	}
+	RSourceTree::RSourceTree() : directories() {}
 	
 	GPB::io::ZeroCopyInputStream * RSourceTree::Open(const std::string & filename){
 		/* first, try to open the file as it is */

Deleted: pkg/src/add.cpp
===================================================================
--- pkg/src/add.cpp	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/src/add.cpp	2010-05-10 13:33:07 UTC (rev 324)
@@ -1,297 +0,0 @@
-#include "rprotobuf.h"
-#include "fieldtypes.h"
-/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
-
-namespace rprotobuf{
-
-	/**
-	 * Add values to a repeated field
-	 *
-	 * @param xp (GPB::Message*) external pointer
-	 * @param field field tag number or name
-	 * @param values values to append
-	 */ 
-	SEXP message_add_values( SEXP xp, SEXP field, SEXP values){
-#ifdef RPB_DEBUG
-Rprintf( "<message_add_values>\n" ) ;
-#endif		
-		GPB::Message* message = GET_MESSAGE_POINTER_FROM_XP( xp) ; 
-		const Reflection * ref = message->GetReflection() ;
-		GPB::FieldDescriptor* field_desc = getFieldDescriptor( message, field );
-		
-		if( values == R_NilValue || LENGTH(values) == 0 ){
-			return(R_NilValue); 
-		}
-		
-		if( field_desc->is_repeated() ){
-			/* first check */
-			switch( field_desc->type() ){
-				case TYPE_ENUM:
-					{
-						CHECK_values_for_enum( field_desc, values) ; 
-						break ;
-					}
-				case TYPE_MESSAGE:
-				case TYPE_GROUP:
-					{
-						CHECK_messages( field_desc, values ) ;
-						break ;
-					}
-				default:
-					{// nothing
-					}
-			}
-
-			int value_size = LENGTH( values ) ;
-			/* then add the values */
-			switch( field_desc->type() ){
-				// {{{ int32
-    			case TYPE_INT32:
-    			case TYPE_SINT32:
-    			case TYPE_SFIXED32:
-    				{
-    					switch( TYPEOF( values ) ){
-    						case INTSXP:
-    						case REALSXP:
-    						case LGLSXP:
-    						case RAWSXP:	
-    							{
-    								for( int i=0; i<value_size; i++){
-    									ref->AddInt32( message, field_desc, GET_int32(values,i) ) ;
-    								}
-    								break ;
-    							}
-    						default: 
-    							{
-    								throwException( "Cannot convert to int32", "ConversionException" ) ; 
-    							}
-    					}
-    					break ;   
-    				}
-				// }}}
-    			
-				// {{{ int64
-				case TYPE_INT64:
-    			case TYPE_SINT64:
-    			case TYPE_SFIXED64:
-    				{
-    					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" ) ; 
-    					}
-    					break ;
-    				}
-    				// }}}	
-    				
-    			// {{{ uint32
-    			case TYPE_UINT32:
-    			case TYPE_FIXED32:
-    				{
-    					switch( TYPEOF( values ) ){
-   							case INTSXP:
-    						case REALSXP:
-    						case LGLSXP:
-    						case RAWSXP:	
-    							{
-    								for( int i=0; i<value_size; i++){
-	    								ref->AddUInt32( message, field_desc, GET_int32(values,i) ) ;
-	    							}
-	    							break ;
-    							}
-    						default: 
-    							throwException( "Cannot convert to uint32", "ConversionException" ) ; 
-    					}
-    					break ;   
-    				}
-				// }}}
-     			
-				// {{{ uint64
-    			case TYPE_UINT64:
-    			case TYPE_FIXED64:
-    				{
-    					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" ) ; 
-    					}
-    					break ;   
-    				}
-				// }}}
-        	
-				// {{{ double
-    			case TYPE_DOUBLE:
-    				{
-    					switch( TYPEOF( values ) ){
-    						case INTSXP:
-    						case REALSXP:
-    						case LGLSXP:
-    						case RAWSXP:	
-    							{
-    								
-    								for( int i=0; i<value_size; i++){
-	    								ref->AddDouble( message, field_desc, GET_double(values,i) ) ;
-	    							}
-	    							break ;
-    							}
-    						default: 
-    							throwException( "Cannot convert to double", "ConversionException" ) ; 
-    					}
-    					break ;   
-    				}
-				// }}}	
-    				
-				// {{{ float
-    			case TYPE_FLOAT:
-    				{
-    					switch( TYPEOF( values ) ){
-    						case INTSXP:
-    						case REALSXP:
-    						case LGLSXP:
-    						case RAWSXP:	
-    							{
-    								
-    								for( int i=0; i<value_size; i++){
-	    								ref->AddFloat( message, field_desc, GET_float(values,i) ) ;
-	    							}
-	    							break ;
-    							}
-    						default: 
-    							throwException( "Cannot convert to float", "ConversionException" ) ; 
-    					}
-    					break ;   
-    				}
-				// }}}	
-    			
-				// {{{ bool
-				case TYPE_BOOL:
-   				{
-    					switch( TYPEOF( values ) ){
-     						case INTSXP:
-    						case REALSXP:
-    						case LGLSXP:
-    						case RAWSXP:	
-    							{
-    								
-    								for( int i=0; i<value_size; i++){
-	    								ref->AddBool( message, field_desc, GET_bool(values,i) ) ;
-	    							}
-	    							break ;
-    							}
-   							default: 
-    							throwException( "Cannot convert to float", "ConversionException" ) ; 
-    					}
-    					break ;   
-    				}
-				// }}}
-				
-     			// {{{ string
-				case TYPE_STRING:
-    			case TYPE_BYTES:
-    				{
-    					if( TYPEOF(values) == STRSXP ){ 
-    						for( int i=0 ; i<value_size; i++){
-				    			ref->AddString( message, field_desc, COPYSTRING( CHAR(STRING_ELT(values,i )) ) ) ;
-				    		}
-    					} else{
-    						throwException( "Cannot convert to string", "ConversionException" ) ;
-    					}
-    					break ; 
-    				}
-				// }}}
-    			
-				// {{{ message
-    			case TYPE_MESSAGE:
-    			case TYPE_GROUP: 
-    				{    
-    					if( TYPEOF(values) == VECSXP )  {
-    						for( int i=0; i<value_size; i++){
-				    			GPB::Message* mess = GET_MESSAGE_POINTER_FROM_S4( VECTOR_ELT( values, i) ) ; 
-				    			/* we already know it is of the correct type because of the 
-				    			  premptive chjeck above */
-				    			
-				    			ref->AddMessage(message, field_desc)->CopyFrom( *mess ) ; 
-				    		}
-				    					
-    					} else{
-    						throwException( "type mismatch, expecting a list of 'Message' objects", "TypeMismatchException" ) ;
-    					}
-    					break ;
-    				}
-    				// }}}
-    			
-				// {{{ enum
-    			case TYPE_ENUM : 
-    				{
-    					const GPB::EnumDescriptor* enum_desc = field_desc->enum_type() ;
-        	
-    					switch( TYPEOF( values ) ){
-    						// {{{ numbers 
-    						case INTSXP:
-    						case REALSXP:
-    						case LGLSXP:
-    						case RAWSXP:
-    							{
-    								for( int i=0; i<value_size; i++){
-	    								int val = GET_int(values, i ); 
-	    								ref->AddEnum( message, field_desc, enum_desc->FindValueByNumber(val) ) ;
-									}
-	    							break ;
-    							}
-							// }}}
-        	
-							// {{{ STRSXP
-    						case STRSXP:
-    							{
-    								for( int i=0; i<value_size; i++){
-	    								std::string val = CHAR( STRING_ELT( values, i) ) ;
-	    								const GPB::EnumValueDescriptor* evd = enum_desc->FindValueByName(val) ;
-	    								ref->AddEnum( message, field_desc, evd ) ; 
-									}
-	    							break ;
-    							}
-							// }}}
-    							
-							// {{{ default
-    						default: 
-    							{
-    								throwException( "cannot set enum value", "WrongTypeEnumValueException" ) ; 
-    							}
-							// }}}
-    					}
-    					break; 
-    				}
-					// }}}
-    			default:
-    				{
-    					// nothing
-    				}
-    		}
-		} else{
-			throwException( "add can only be used on repeated fields", "NotRepeatedFieldException" ) ;
-		}
-		
-		
-#ifdef RPB_DEBUG
-Rprintf( "</message_add_values>\n" ) ;
-#endif		
-		return( R_NilValue) ; 
-	}
-	
-}
-

Deleted: pkg/src/completion.cpp
===================================================================
--- pkg/src/completion.cpp	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/src/completion.cpp	2010-05-10 13:33:07 UTC (rev 324)
@@ -1,74 +0,0 @@
-#include "rprotobuf.h"
-
-namespace rprotobuf{
-
-/**
- * returns the field names of the message
- *
- * @param xp external pointer to a Message
- *
- * @return field names, as an R character vector (STRSXP)
- */
-SEXP getMessageFieldNames( SEXP xp ){
-	Rcpp::XPtr<GPB::Message> message(xp); 
-	return getMessageFieldNames(message);
-}	
-
-SEXP getMessageFieldNames_( const Rcpp::XPtr<GPB::Message>& message ){
-	
-	/* the message descriptor */
-	const GPB::Descriptor* desc = message->GetDescriptor() ;
-	
-	int nfields = desc->field_count() ; 
-	Rcpp::CharacterVector res(nfields) ;
-	for(int i=0; i<nfields; i++){
-		res[i] = desc->field(i)->name() ;
-	}
-	return( res );
-}
-
-/**
- * returns the names of the members contained in the descriptor
- * (nested types, enums, fields)
- *
- * @param xp external pointer to a Descriptor
- *
- * @return member names, as an R character vector (STRSXP)
- */
-SEXP getDescriptorMemberNames( SEXP xp ){
-	
-	/* the message descriptor */
-	GPB::Descriptor* desc = (GPB::Descriptor*)EXTPTR_PTR(xp) ;
-	
-	int nfields = desc->field_count() ;
-	int ntypes  = desc->nested_type_count() ;
-	int nenums  = desc->enum_type_count() ;
-	
-	SEXP res = PROTECT( Rf_allocVector(STRSXP, nfields + ntypes + nenums ) ) ;
-	int i=0;
-	int j=0; 
-	while( i<nfields){
-		SET_STRING_ELT( res, j, Rf_mkChar( desc->field(i)->name().c_str() ) ) ;
-		i++; 
-		j++;
-	}
-	i=0; 
-	while( i<ntypes){
-		SET_STRING_ELT( res, j, Rf_mkChar( desc->nested_type(i)->name().c_str() ) ) ;
-		i++; 
-		j++;
-	}
-	i = 0; 
-	while( i<nenums){
-		SET_STRING_ELT( res, j, Rf_mkChar( desc->enum_type(i)->name().c_str() ) ) ;
-		i++; 
-		j++;
-	}
-	
-	UNPROTECT(1); 
-	return( res );
-}
-
-
-} // namespace rprotobuf
-

Modified: pkg/src/exceptions.cpp
===================================================================
--- pkg/src/exceptions.cpp	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/src/exceptions.cpp	2010-05-10 13:33:07 UTC (rev 324)
@@ -2,6 +2,8 @@
 
 namespace rprotobuf{
 
+/* FIXME: this has got to disappear */	
+	
 /**
  * create a call to throw an evaluate it
  *

Modified: pkg/src/extractors.cpp
===================================================================
--- pkg/src/extractors.cpp	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/src/extractors.cpp	2010-05-10 13:33:07 UTC (rev 324)
@@ -3,53 +3,7 @@
 #include "Rcppsupport.h"
 
 namespace rprotobuf{
-
-	/* this is only to be called for repeated fields */
-	int MESSAGE_GET_REPEATED_INT( GPB::Message* message, GPB::FieldDescriptor* field_desc, int index ){
-		
-		const GPB::Reflection* ref = message->GetReflection() ; 
-		
-		switch( field_desc->type() ){
-			case TYPE_INT32:
-    		case TYPE_SINT32:
-    		case TYPE_SFIXED32:
-    			return (int) ref->GetRepeatedInt32( *message, field_desc, index ) ;
-    		case TYPE_INT64:
-    		case TYPE_SINT64:
-    		case TYPE_SFIXED64:
-    			return (int) ref->GetRepeatedInt64( *message, field_desc, index ) ;
-    		case TYPE_UINT32:
-    		case TYPE_FIXED32:
-    			return (int) ref->GetRepeatedUInt32( *message, field_desc, index ) ;
-    		case TYPE_UINT64:
-    		case TYPE_FIXED64:
-    			return (int) ref->GetRepeatedUInt64( *message, field_desc, index ) ;
-    		case TYPE_ENUM:
-    			return ref->GetRepeatedEnum( *message, field_desc, index )->number() ;
-    		default:
-    			throwException( "cannot cast to int", "CastException" ) ; 
-		}
-		return 0 ; // -Wall
-	}
 	
-	/* this is only to be called for repeated fields */
-	double MESSAGE_GET_REPEATED_DOUBLE( GPB::Message* message, GPB::FieldDescriptor* field_desc, int index ){
-		
-		const GPB::Reflection* ref = message->GetReflection() ; 
-		
-		switch( field_desc->type() ){
-			case TYPE_FLOAT:
-    			return (double) ref->GetRepeatedFloat( *message, field_desc, index ) ;
-    		case TYPE_DOUBLE:
-    			return (double) ref->GetRepeatedDouble( *message, field_desc, index ) ;
-    		default:
-    			throwException( "cannot cast to double", "CastException" ) ; 
-		}
-		return 0 ; // -Wall
-	}
-	
-	
-	
 /**
  * extract a field from a message
  *
@@ -166,62 +120,12 @@
     			return Rcpp::wrap( ref->GetEnum( *message, fieldDesc )->number() ) ;
     		
     		case CPPTYPE_MESSAGE:
-    			return new_RS4_Message_( CLONE( &ref->GetMessage( *message, fieldDesc ) ) ) ;
+    			return S4_Message_( CLONE( &ref->GetMessage( *message, fieldDesc ) ) ) ;
     			break ;
     	}
     }
     return R_NilValue ; /* -Wall */
 }
 
-/**
- * extract a method descriptor from a service descriptor using its
- * name or position
- *
- * @param pointer (GPB::ServiceDescriptor*) external pointer
- * @param name name or position of the method
- */
-SEXP get_service_method( SEXP pointer, SEXP name ){
-
-	/* grab the Message pointer */
-	Rcpp::XPtr<GPB::ServiceDescriptor> desc(pointer) ;
-
-	GPB::MethodDescriptor* method_desc = static_cast<GPB::MethodDescriptor*>(0);
-	
-	switch( TYPEOF( name) ){
-	case STRSXP:
-		{
-			/* what we are looking for */
-			const char * what = CHAR( STRING_ELT(name, 0 ) ) ;
-			
-			/* the method descriptor */
-			method_desc = (GPB::MethodDescriptor*)desc->FindMethodByName( what ) ;
-			
-			break ;
-		}
-	case REALSXP:
-		{
-			
-			/* the method descriptor */
-			method_desc = (GPB::MethodDescriptor*)desc->method( (int)REAL(name)[0] ) ;
-			
-			break ;
-		}
-	case INTSXP: 
-		{
-			/* the method descriptor */
-			method_desc = (GPB::MethodDescriptor*)desc->method( INTEGER(name)[0] ) ;
-			
-			break ;
-		}
-	}
-	
-	if( !method_desc ){
-		throwException( "could not get MethodDescriptor", "NoSuchMethodException" ) ;
-	}
-	
-	return S4_MethodDescriptor( method_desc ); 
-	
-}
-
 } // namespace rprotobuf
 

Deleted: pkg/src/fileDescriptor.cpp
===================================================================
--- pkg/src/fileDescriptor.cpp	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/src/fileDescriptor.cpp	2010-05-10 13:33:07 UTC (rev 324)
@@ -1,54 +0,0 @@
-#include "rprotobuf.h"
-
-namespace rprotobuf{
-
-	/**
-	 * get the fileDescriptor associated with a message
-	 */
-	SEXP get_message_file_descriptor(SEXP xp){
-		GPB::Message* message = GET_MESSAGE_POINTER_FROM_XP( xp ) ;
-		return S4_FileDescriptor( message->GetDescriptor()->file() ); 
-	}
-	
-	/**
-	 * get the fileDescriptor associated with a message descriptor
-	 */
-	SEXP get_descriptor_file_descriptor(SEXP xp){
-		GPB::Descriptor* desc = (GPB::Descriptor*) EXTPTR_PTR( xp ) ;
-		return S4_FileDescriptor( desc->file() ); 
-	}
-	
-	/**
-	 * get the fileDescriptor associated with an enum descriptor
-	 */
-	SEXP get_enum_file_descriptor(SEXP xp){
-		GPB::EnumDescriptor* desc = (GPB::EnumDescriptor*) EXTPTR_PTR( xp ) ;
-		return S4_FileDescriptor( desc->file() ); 
-	}
-	
-	/**
-	 * get the fileDescriptor associated with a field descriptor
-	 */
-	SEXP get_field_file_descriptor(SEXP xp){
-		GPB::FieldDescriptor* desc = (GPB::FieldDescriptor*) EXTPTR_PTR( xp ) ;
-		return S4_FileDescriptor( desc->file() ); 
-	}
-	
-	/**
-	 * get the fileDescriptor associated with a service descriptor
-	 */
-	SEXP get_service_file_descriptor(SEXP xp){
-		GPB::ServiceDescriptor* desc = (GPB::ServiceDescriptor*) EXTPTR_PTR( xp ) ;
-		return S4_FileDescriptor( desc->file() ); 
-	}
-	
-	/**
-	 * get the fileDescriptor associated with a service descriptor
-	 */
-	SEXP get_method_file_descriptor(SEXP xp){
-		GPB::MethodDescriptor* desc = (GPB::MethodDescriptor*) EXTPTR_PTR( xp ) ;
-		return S4_FileDescriptor( desc->service()->file() ); 
-	}
-	
-	
-} // namespace rprotobuf

Deleted: pkg/src/identical.cpp
===================================================================
--- pkg/src/identical.cpp	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/src/identical.cpp	2010-05-10 13:33:07 UTC (rev 324)
@@ -1,208 +0,0 @@
-#include "rprotobuf.h"
-#include "fieldtypes.h"
-
-#define SAME(x,y,tol) ( (tol==0.0 && x == y ) ||  ( ( (x-y)*(x-y) < tol*tol ) ? 1 : 0 ) ) 
-
-namespace rprotobuf {
-
-	Rboolean identical_messages_( GPB::Message* m1,  GPB::Message* m2, double tol ){
-		const GPB::Descriptor* d1 = m1->GetDescriptor() ;
-		const GPB::Descriptor* d2 = m2->GetDescriptor() ;
-		
-		/* first of all, check if this is the same message type */
-		if( d1 != d2 ){
-			return _FALSE_ ;
-		}
-		
-		const GPB::Reflection* ref = m2->GetReflection() ;
-		
-		/* iterate field descriptors */
-		int nf = d1->field_count() ;
-		for( int i=0; i<nf; i++){
-			const GPB::FieldDescriptor* field_desc = d1->field( i ) ;
-			
-			if( field_desc->is_repeated() ){
-				
-				/* test if the size differs */
-				int fs = ref->FieldSize( *m1, field_desc) ;
-				if( fs != ref->FieldSize( *m2, field_desc) ) return _FALSE_ ;
-				
-				/* test all items */
-				switch( field_desc->type() ){
-					case TYPE_INT32:
-    				case TYPE_SINT32:
-    				case TYPE_SFIXED32:
-    					{
-    						for( int j=0; j<fs; j++){
-    							if( ref->GetRepeatedInt32( *m1, field_desc, j ) != ref->GetRepeatedInt32( *m2, field_desc, j ) ) return _FALSE_ ; 
-    						}
-    						break ;
-    					}
-    				case TYPE_INT64:
-    				case TYPE_SINT64:
-    				case TYPE_SFIXED64:
-    					{
-    						for( int j=0; j<fs; j++){
-    							if( ref->GetRepeatedInt64( *m1, field_desc, j ) != ref->GetRepeatedInt64( *m2, field_desc, j ) ) return _FALSE_ ; 
-    						}
-    						break ;
-    					}
-	    			case TYPE_UINT32:
-	    			case TYPE_FIXED32:
-	    				{
-	    					for( int j=0; j<fs; j++){
-    							if( ref->GetRepeatedUInt32( *m1, field_desc, j ) != ref->GetRepeatedUInt32( *m2, field_desc, j ) ) return _FALSE_ ; 
-    						}
-    						break ;
-	    				}
-	    			case TYPE_UINT64:
-	    			case TYPE_FIXED64:
-	    				{
-	    					for( int j=0; j<fs; j++){
-    							if( ref->GetRepeatedUInt64( *m1, field_desc, j ) != ref->GetRepeatedUInt64( *m2, field_desc, j ) ) return _FALSE_ ; 
-    						}
-    						break ;	    					
-	    				}
-	    			case TYPE_DOUBLE:
-	    				{
-	    					for( int j=0; j<fs; j++){
-    							if( !SAME( ref->GetRepeatedDouble( *m1, field_desc, j ), ref->GetRepeatedDouble( *m2, field_desc, j ), tol) ) return _FALSE_ ; 
-    						}
-    						break ;	    					
-	    				}
-	    			case TYPE_FLOAT:
-	    				{
-	    					for( int j=0; j<fs; j++){
-    							if( !SAME( ref->GetRepeatedFloat( *m1, field_desc, j ), ref->GetRepeatedFloat( *m2, field_desc, j ), tol) ) return _FALSE_ ; 
-    						}
-    						break ;	    					
-	    				}
-	    			case TYPE_BOOL:
-	    				{
-	    					for( int j=0; j<fs; j++){
-    							if( ref->GetRepeatedBool( *m1, field_desc, j ) != ref->GetRepeatedBool( *m2, field_desc, j ) ) return _FALSE_ ; 
-    						}
-    						break ;	    					
-	    				}
-					case TYPE_STRING:
-	    			case TYPE_BYTES:
-	    				{
-	    					for( int j=0; j<fs; j++){
-    							if( ref->GetRepeatedString( *m1, field_desc, j ) != ref->GetRepeatedString( *m2, field_desc, j ) ) return _FALSE_ ; 
-    						}
-    						break ;	    					
-	    				}
-	    			case TYPE_ENUM :
-	    				{
-	    					for( int j=0; j<fs; j++){
-    							if( ref->GetRepeatedEnum( *m1, field_desc, j ) != ref->GetRepeatedEnum( *m2, field_desc, j ) ) return _FALSE_ ; 
-    						}
-    						break ;
-	    				}
-	    			case TYPE_MESSAGE:
-	    			case TYPE_GROUP:
-	    				{
-	    					for( int j=0; j<fs; j++){
-    							const GPB::Message* mm1 = &ref->GetRepeatedMessage( *m1, field_desc, j ) ;
-    							const GPB::Message* mm2 = &ref->GetRepeatedMessage( *m2, field_desc, j ) ;
-	    						if( !identical_messages_( (GPB::Message*)mm1, (GPB::Message*)mm2, tol ) ){
-	    							return _FALSE_ ;
-	    						}
-    						}
-    						break ;
-	    				}
-	    			default:
-	    				throwException( "unknown type" , "UnknownTypeException" ) ;
-				}
-				
-			} else {
-				
-				switch( field_desc->type() ){
-					case TYPE_INT32:
-    				case TYPE_SINT32:
-    				case TYPE_SFIXED32:
-    					{
-    						if( ref->GetInt32( *m1, field_desc) != ref->GetInt32( *m2, field_desc ) ) return _FALSE_ ; 
-    						break ;
-    					}
-    				case TYPE_INT64:
-    				case TYPE_SINT64:
-    				case TYPE_SFIXED64:
-    					{
-    						if( ref->GetInt64( *m1, field_desc) != ref->GetInt64( *m2, field_desc) ) return _FALSE_ ; 
-    						break ;
-    					}
-	    			case TYPE_UINT32:
-	    			case TYPE_FIXED32:
-	    				{
-	    					if( ref->GetUInt32( *m1, field_desc ) != ref->GetUInt32( *m2, field_desc ) ) return _FALSE_ ; 
-    						break ;
-	    				}
-	    			case TYPE_UINT64:
-	    			case TYPE_FIXED64:
-	    				{
-	    					if( ref->GetUInt64( *m1, field_desc ) != ref->GetUInt64( *m2, field_desc ) ) return _FALSE_ ; 
-    						break ;	    					
-	    				}
-	    			case TYPE_DOUBLE:
-	    				{
-	    					if( ref->GetDouble( *m1, field_desc ) != ref->GetDouble( *m2, field_desc ) ) return _FALSE_ ; 
-    						break ;	    					
-	    				}
-	    			case TYPE_FLOAT:
-	    				{
-	    					if( ref->GetFloat( *m1, field_desc ) != ref->GetFloat( *m2, field_desc ) ) return _FALSE_ ; 
-    						break ;	    					
-	    				}
-	    			case TYPE_BOOL:
-	    				{
-	    					if( ref->GetBool( *m1, field_desc ) != ref->GetBool( *m2, field_desc ) ) return _FALSE_ ; 
-    						break ;	    					
-	    				}
-					case TYPE_STRING:
-	    			case TYPE_BYTES:
-	    				{
-	    					if( ref->GetString( *m1, field_desc ) != ref->GetString( *m2, field_desc ) ) return _FALSE_ ; 
-    						break ;	    					
-	    				}
-	    			case TYPE_ENUM :
-	    				{
-	    					if( ref->GetEnum( *m1, field_desc) != ref->GetEnum( *m2, field_desc ) ) return _FALSE_ ; 
-    						break ;
-	    				}
-	    			case TYPE_MESSAGE:
-	    			case TYPE_GROUP:
-	    				{
-	    					const GPB::Message* mm1 = &ref->GetMessage( *m1, field_desc ) ;
-    						const GPB::Message* mm2 = &ref->GetMessage( *m2, field_desc ) ;
-	    					if( !identical_messages_( (GPB::Message*)mm1, (GPB::Message*)mm2, tol ) ){
-	    						return _FALSE_ ;
-	    					}
-    						break ;
-	    				}
-	    			default:
-	    				throwException( "unknown type" , "UnknownTypeException" ) ;
-				}
-				
-			}
-		}
-		
-		/* finally */
-		return _TRUE_ ;
-		
-	}
-	
-	SEXP identical_messages( SEXP xp1, SEXP xp2){
-		GPB::Message* m1 = GET_MESSAGE_POINTER_FROM_XP( xp1 ) ;
-		GPB::Message* m2 = GET_MESSAGE_POINTER_FROM_XP( xp2 ) ;
-		return Rf_ScalarLogical( identical_messages_( m1, m2, 0.0 ) ) ;
-	}
-	
-	SEXP all_equal_messages( SEXP xp1, SEXP xp2, SEXP tol){
-		GPB::Message* m1 = GET_MESSAGE_POINTER_FROM_XP( xp1 ) ;
-		GPB::Message* m2 = GET_MESSAGE_POINTER_FROM_XP( xp2 ) ;
-		return Rf_ScalarLogical( identical_messages_( m1, m2, REAL(tol)[0] ) ) ;
-	}
-	
-
-} // namespace rprotobuf

Deleted: pkg/src/merge.cpp
===================================================================
--- pkg/src/merge.cpp	2010-05-08 11:57:24 UTC (rev 323)
+++ pkg/src/merge.cpp	2010-05-10 13:33:07 UTC (rev 324)
@@ -1,35 +0,0 @@
-#include "rprotobuf.h"
-
-namespace rprotobuf{
-
-/**
- * creates a new message by merging two messages of the same type
- *
- * @param xp1 external pointer to a GPB::Message*
- * @param xp2 external pointer to a GPB::Message*
- *
- * @return a new message, as an R object of "Message" S4 class
- */
-SEXP merge_message( SEXP xp1, SEXP xp2){
-
-#ifdef RPB_DEBUG
-Rprintf( "<merge_message>\n" ) ;
-#endif
-
-	// we assume both messages are of the same type
-	// this is checked on the R side	
-	GPB::Message* m1 = GET_MESSAGE_POINTER_FROM_XP( xp1 );
-	GPB::Message* m2 = GET_MESSAGE_POINTER_FROM_XP( xp2 );
-	GPB::Message* merged = m1->New() ; 
-	merged->MergeFrom( *m1 ) ; 
-	merged->MergeFrom( *m2 ); 
-	SEXP res = PROTECT( new_RS4_Message_( merged ) ) ;
-	UNPROTECT(1) ; /* res */
-	
-#ifdef RPB_DEBUG
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/rprotobuf -r 324


More information about the Rprotobuf-commits mailing list