[Rprotobuf-commits] r365 - in pkg: inst/doc/RProtoBuf src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 30 10:56:17 CEST 2010


Author: romain
Date: 2010-07-30 10:56:17 +0200 (Fri, 30 Jul 2010)
New Revision: 365

Modified:
   pkg/inst/doc/RProtoBuf/RProtoBuf.Rnw
   pkg/src/extractors.cpp
   pkg/src/mutators.cpp
   pkg/src/rprotobuf.cpp
Log:
a bit further (noth there yet)

Modified: pkg/inst/doc/RProtoBuf/RProtoBuf.Rnw
===================================================================
--- pkg/inst/doc/RProtoBuf/RProtoBuf.Rnw	2010-07-30 08:32:49 UTC (rev 364)
+++ pkg/inst/doc/RProtoBuf/RProtoBuf.Rnw	2010-07-30 08:56:17 UTC (rev 365)
@@ -105,9 +105,10 @@
 Using the \texttt{file} argument, one can specify one or several file
 paths that ought to be proto files.
 
-<<>>=
+<<>>=     
 proto.dir <- system.file( "proto", package = "RProtoBuf" )
 proto.file <- file.path( proto.dir, "addressbook.proto" )
+<<eval=FALSE>>=     
 readProtoFiles( proto.file )
 @
 
@@ -117,6 +118,7 @@
 
 <<>>=
 dir( proto.dir, pattern = "\\.proto$", full.names = TRUE )
+<<eval=FALSE>>=
 readProtoFiles( dir = proto.dir )
 @
 
@@ -127,7 +129,7 @@
 package. A typical use for this argument is in the \texttt{.onLoad}
 function of a package.
 
-<<>>=
+<<eval=FALSE>>=
 readProtoFiles( package = "RProtoBuf" )
 @
 

Modified: pkg/src/extractors.cpp
===================================================================
--- pkg/src/extractors.cpp	2010-07-30 08:32:49 UTC (rev 364)
+++ pkg/src/extractors.cpp	2010-07-30 08:56:17 UTC (rev 365)
@@ -28,40 +28,8 @@
 	/* the message descriptor */
 	const GPB::Descriptor* desc = message->GetDescriptor() ;
 	
-	GPB::FieldDescriptor* field_desc = static_cast<GPB::FieldDescriptor*>(0);
+	GPB::FieldDescriptor* field_desc = getFieldDescriptor( message, name ) ;
 	
-	switch( TYPEOF( name) ){
-	case STRSXP:
-		{
-			/* what we are looking for */
-			const char * what = CHAR( STRING_ELT(name, 0 ) ) ;
-			
-			/* the field descriptor */
-			field_desc = (GPB::FieldDescriptor*)desc->FindFieldByName( what ) ;
-			
-			break ;
-		}
-	case REALSXP:
-		{
-			
-			/* the field descriptor */
-			field_desc = (GPB::FieldDescriptor*)desc->FindFieldByNumber( static_cast<int>( REAL(name)[0] ) ) ;
-			
-			break ;
-		}
-	case INTSXP: 
-		{
-			/* the field descriptor */
-			field_desc = (GPB::FieldDescriptor*)desc->FindFieldByNumber( INTEGER(name)[0] ) ;
-			
-			break ;
-		}
-	}
-	
-	if( !field_desc ){
-		throwException( "could not get FieldDescriptor for field", "NoSuchFieldException" ) ;
-	}
-	
 #ifdef RPB_DEBUG
 Rprintf( "</getMessageField>\n" ) ;
 #endif

Modified: pkg/src/mutators.cpp
===================================================================
--- pkg/src/mutators.cpp	2010-07-30 08:32:49 UTC (rev 364)
+++ pkg/src/mutators.cpp	2010-07-30 08:56:17 UTC (rev 365)
@@ -1029,9 +1029,7 @@
 }
 
 RCPP_FUNCTION_VOID_2( update_message, Rcpp::XPtr<GPB::Message> message, Rcpp::List list ){
-
 	Rcpp::CharacterVector names = list.attr( "names" ) ;
-	
 	int n = list.size() ;
 	for( int i=0; i<n; i++){
 		setMessageField( message, names[i], list[i] ); 

Modified: pkg/src/rprotobuf.cpp
===================================================================
--- pkg/src/rprotobuf.cpp	2010-07-30 08:32:49 UTC (rev 364)
+++ pkg/src/rprotobuf.cpp	2010-07-30 08:56:17 UTC (rev 365)
@@ -190,15 +190,19 @@
 	GPB::FieldDescriptor* field_desc = (GPB::FieldDescriptor*)0;
 	const GPB::Descriptor* desc = message->GetDescriptor() ;
 	switch( TYPEOF(name) ){
+		case CHARSXP:
+			{
+				field_desc = (GPB::FieldDescriptor*)desc->FindFieldByName( CHAR(name) ) ;
+				break ;	
+			}
 		case STRSXP:
 			{
-				const char * what = CHAR( STRING_ELT(name, 0 ) ) ;
-				field_desc = (GPB::FieldDescriptor*)desc->FindFieldByName( what ) ;
+				field_desc = (GPB::FieldDescriptor*)desc->FindFieldByName( CHAR( STRING_ELT(name, 0 ) ) ) ;
 				break ;
 			}
 		case REALSXP: 
 			{
-				field_desc = (GPB::FieldDescriptor*)desc->FindFieldByNumber( (int)REAL(name)[0] ) ;
+				field_desc = (GPB::FieldDescriptor*)desc->FindFieldByNumber( static_cast<int>( REAL(name)[0] ) ) ;
 				break ;
 			}
 		case INTSXP:
@@ -207,11 +211,9 @@
 				break ;
 			}
 	}
-	
 	if( !field_desc ){
 		throwException( "could not get FieldDescriptor for field", "NoSuchFieldException" ) ;
 	}
-	
 	return field_desc ;
 }
 



More information about the Rprotobuf-commits mailing list