[Rprotobuf-commits] r660 - / pkg pkg/R pkg/man pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Dec 31 03:41:57 CET 2013


Author: murray
Date: 2013-12-31 03:41:53 +0100 (Tue, 31 Dec 2013)
New Revision: 660

Modified:
   STYLE
   pkg/ChangeLog
   pkg/R/size.R
   pkg/man/size.Rd
   pkg/src/wrapper_Message.cpp
Log:
Fix size<- by using the correct C++ function name, and add
documentation and examples of using this function.

Replace two calls to Rf_error with Rcpp_error so that we unwind the
call stack to deallocate objects before jumping to R's error handing
routines.



Modified: STYLE
===================================================================
--- STYLE	2013-12-31 01:38:53 UTC (rev 659)
+++ STYLE	2013-12-31 02:41:53 UTC (rev 660)
@@ -47,10 +47,6 @@
 We exclude sisocks.h from style issues as it is written separately by
 Simon Urbanek.
 
-We exclude mutators.cpp and extractors.cpp temporarily as many other
-changes were made to those files recently and we want to allow more
-review before obfuscating the content changes with whitespace changes.
-
 We exclude Rcppsupport.h and RcppMacros.h because I don't like the
 result.  I want BEGIN_RCPP on its own line, for example.
 

Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2013-12-31 01:38:53 UTC (rev 659)
+++ pkg/ChangeLog	2013-12-31 02:41:53 UTC (rev 660)
@@ -5,7 +5,17 @@
 	  optional protobuf fields.
 	* src/extractors.cpp (rprotobuf): Correct handling of uint32 for
 	  repeated fields.
-	
+	* src/wrapper_Message.cpp (rprotobuf): Remove Rf_error in favor of
+	  Rcpp_error so that we throw an exception and unwind the stack to
+	  deallocate objects before jumping to R' serror.
+	* R/size.R: Correct an incorrect method name that prevented size<-
+	  from working.
+	* man/size.Rd: Document the behavior of size<-
+	* (C++): Ran all the C++ files and most of the headers through
+	  clang-format as described in the STYLE file on R-Forge.
+	  Basically, we now use 4-char indents and 100-char limit for line
+	  wrap.
+
 2013-12-28  Murray Stokely  <mstokely at google.com>
 
 	* src/extractors.cpp (rprotobuf): Correct handling of uint32 for

Modified: pkg/R/size.R
===================================================================
--- pkg/R/size.R	2013-12-31 01:38:53 UTC (rev 659)
+++ pkg/R/size.R	2013-12-31 02:41:53 UTC (rev 660)
@@ -31,7 +31,7 @@
 	value <- as.integer( value )[1]
 	
 	if( is.character( field ) || is.numeric( field ) ){
-		.Call( "set_field_size", object at pointer, field, value, PACKAGE = "RProtoBuf" )
+		.Call( "Message__set_field_size", object at pointer, field, value, PACKAGE = "RProtoBuf" )
 	} else{
 		stop( "field should be a character or a number" )
 	}

Modified: pkg/man/size.Rd
===================================================================
--- pkg/man/size.Rd	2013-12-31 01:38:53 UTC (rev 659)
+++ pkg/man/size.Rd	2013-12-31 02:41:53 UTC (rev 660)
@@ -11,6 +11,12 @@
 For non repeated fields, the size is 1 if the message has the field, 0 otherwise. 
 
 For repeated fields, the size is the number of objects in the array.
+
+For repeated fields, the size can also be assigned to in order to shrink
+or grow the vector.  Numeric types are given a default value of 0 when
+the new size is greater than the existing size.  Character types are
+given a default value of "".  Growing a repeated field in this way is
+not supported for message, group, and enum types.
 }
 \section{Methods}{
 \describe{
@@ -26,5 +32,12 @@
 
 test$add("repeated_int32", 1:10)
 test$size("repeated_int32")
+test$repeated_int32
+
+size(test, "repeated_int32") <- 5
+test$repeated_int32
+
+size(test, "repeated_int32") <- 15
+test$repeated_int32
 }
 \keyword{methods}

Modified: pkg/src/wrapper_Message.cpp
===================================================================
--- pkg/src/wrapper_Message.cpp	2013-12-31 01:38:53 UTC (rev 659)
+++ pkg/src/wrapper_Message.cpp	2013-12-31 02:41:53 UTC (rev 660)
@@ -335,16 +335,12 @@
                     case TYPE_MESSAGE:
                     case TYPE_GROUP: {
                         /* fill with the prototype for that message type */
-                        Rf_error(
-                            "growing repeated messages not implemented yet, "
-                            "patches welcome");
+                        Rcpp_error("growing repeated messages not implemented, patches welcome");
                         break;
                     }
                     case TYPE_ENUM: {
                         /* fill with the prototype for that message type */
-                        Rf_error(
-                            "growing repeated enum not implemented yet, "
-                            "patches welcome");
+                        Rcpp_error("growing repeated enums not implemented yet, patches welcome");
                         break;
                     }
                 } /* switch */



More information about the Rprotobuf-commits mailing list