[Rprotobuf-commits] r472 - patches
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Aug 9 14:09:38 CEST 2012
Author: edd
Date: 2012-08-09 14:09:38 +0200 (Thu, 09 Aug 2012)
New Revision: 472
Added:
patches/patch_by_Murray_rprotobuf_r471-1.diff
patches/patch_by_Murray_rprotobuf_r471-2.diff
Log:
two more patches by Murray
Added: patches/patch_by_Murray_rprotobuf_r471-1.diff
===================================================================
--- patches/patch_by_Murray_rprotobuf_r471-1.diff (rev 0)
+++ patches/patch_by_Murray_rprotobuf_r471-1.diff 2012-08-09 12:09:38 UTC (rev 472)
@@ -0,0 +1,183 @@
+Index: man/type.Rd
+===================================================================
+--- man/type.Rd (revision 453)
++++ man/type.Rd (working copy)
+@@ -36,12 +36,11 @@
+ \alias{CPPTYPE_STRING}
+ \alias{CPPTYPE_MESSAGE}
+
+-\title{Gets the type or the c++ type of a field}
++\title{Gets the type or the C++ type of a field}
+ \description{
+-Gets the type or the c++ type of a field
++Gets the type or the C++ type of a field
+ }
+ \seealso{
+ The method is implemented for the \linkS4class{FieldDescriptor} class
+ }
+ \keyword{methods}
+-
+Index: man/FieldDescriptor-class.Rd
+===================================================================
+--- man/FieldDescriptor-class.Rd (revision 453)
++++ man/FieldDescriptor-class.Rd (working copy)
+@@ -97,6 +97,15 @@
+
+ # or as a pseudo method
+ Person$email$as.character()
++
++Person$email$is_required()
++Person$email$is_optional()
++Person$email$is_repeated()
++
++Person$email$has_default_value()
++Person$email$default_value()
++
++Person$email$is_extension()
+ }
+ }
+ \keyword{classes}
+Index: man/size.Rd
+===================================================================
+--- man/size.Rd (revision 453)
++++ man/size.Rd (working copy)
+@@ -16,5 +16,15 @@
+ \describe{
+ \item{\code{signature(object = "Message")}}{Number of objects in a message field}
+ }}
++\examples{
++unitest.proto.file <- system.file("unitTests", "data", "unittest.proto",
++ package = "RProtoBuf" )
++readProtoFiles(file = unitest.proto.file)
++
++test <- new(protobuf_unittest.TestAllTypes)
++test$size("optional_int32")
++
++test$add("repeated_int32", 1:10)
++test$size("test$repeated_int32")
++}
+ \keyword{methods}
+-
+Index: man/has.Rd
+===================================================================
+--- man/has.Rd (revision 453)
++++ man/has.Rd (working copy)
+@@ -22,5 +22,15 @@
+ \item{has}{\code{signature(object = "Message")}: Indicates if the message has a given field.}
+ }
+ }
++\examples{
++unitest.proto.file <- system.file("unitTests", "data", "unittest.proto",
++ package = "RProtoBuf" )
++readProtoFiles(file = unitest.proto.file)
++
++test <- new(protobuf_unittest.TestAllTypes)
++test$has("optional_int32")
++
++test$add("repeated_int32", 1:10)
++test$has("repeated_int32")
++}
+ \keyword{methods}
+-
+Index: R/wrapper_FieldDescriptor.R
+===================================================================
+--- R/wrapper_FieldDescriptor.R (revision 453)
++++ R/wrapper_FieldDescriptor.R (working copy)
+@@ -3,14 +3,14 @@
+ standardGeneric("is_extension")
+ } )
+ setMethod( "is_extension", "FieldDescriptor", function(object){
+- .Call( "FieldDescriptor_is_extension", object at pointer, PACKAGE = "RProtoBuf" )
++ .Call( "FieldDescriptor__is_extension", object at pointer, PACKAGE = "RProtoBuf" )
+ })
+
+ setGeneric( "number", function(object){
+ standardGeneric( "number" )
+ } )
+ setMethod( "number", "FieldDescriptor", function(object){
+- .Call( "FieldDescriptor_number", object at pointer, PACKAGE = "RProtoBuf" )
++ .Call( "FieldDescriptor__number", object at pointer, PACKAGE = "RProtoBuf" )
+ } )
+
+ TYPE_DOUBLE <- 1L
+@@ -38,7 +38,7 @@
+ standardGeneric( "type" )
+ } )
+ setMethod( "type", "FieldDescriptor", function(object, as.string = FALSE){
+- type <- .Call( "FieldDescriptor_type", object at pointer, PACKAGE = "RProtoBuf" )
++ type <- .Call( "FieldDescriptor__type", object at pointer, PACKAGE = "RProtoBuf" )
+ if( as.string ) .TYPES[type] else type
+ } )
+
+@@ -59,7 +59,7 @@
+ standardGeneric( "cpp_type" )
+ } )
+ setMethod( "cpp_type", "FieldDescriptor", function(object, as.string = FALSE){
+- cpptype <- .Call( "FieldDescriptor_cpp_type", object at pointer, PACKAGE = "RProtoBuf" )
++ cpptype <- .Call( "FieldDescriptor__cpp_type", object at pointer, PACKAGE = "RProtoBuf" )
+ if( as.string ) .CPPTYPES[cpptype] else cpptype
+ } )
+
+@@ -72,7 +72,7 @@
+ standardGeneric( "label" )
+ } )
+ setMethod( "label", "FieldDescriptor", function(object, as.string = FALSE){
+- lab <- .Call( "FieldDescriptor_label", object at pointer, PACKAGE = "RProtoBuf" )
++ lab <- .Call( "FieldDescriptor__label", object at pointer, PACKAGE = "RProtoBuf" )
+ if( as.string ) .LABELS[lab] else lab
+ } )
+
+@@ -80,35 +80,35 @@
+ standardGeneric( "is_repeated" )
+ } )
+ setMethod( "is_repeated", "FieldDescriptor", function(object){
+- .Call( "FieldDescriptor_is_repeated", object at pointer, PACKAGE = "RProtoBuf" )
++ .Call( "FieldDescriptor__is_repeated", object at pointer, PACKAGE = "RProtoBuf" )
+ } )
+
+ setGeneric( "is_optional", function(object){
+ standardGeneric( "is_optional" )
+ } )
+ setMethod( "is_optional", "FieldDescriptor", function(object){
+- .Call( "FieldDescriptor_is_optional", object at pointer, PACKAGE = "RProtoBuf" )
++ .Call( "FieldDescriptor__is_optional", object at pointer, PACKAGE = "RProtoBuf" )
+ } )
+
+ setGeneric( "is_required", function(object ){
+ standardGeneric( "is_required" )
+ } )
+ setMethod( "is_required", "FieldDescriptor", function(object){
+- .Call( "FieldDescriptor_is_required", object at pointer, PACKAGE = "RProtoBuf" )
++ .Call( "FieldDescriptor__is_required", object at pointer, PACKAGE = "RProtoBuf" )
+ } )
+
+ setGeneric( "has_default_value", function(object ){
+ standardGeneric( "has_default_value" )
+ } )
+ setMethod( "has_default_value", "FieldDescriptor", function(object){
+- .Call( "FieldDescriptor_has_default_value", object at pointer, PACKAGE = "RProtoBuf" )
++ .Call( "FieldDescriptor__has_default_value", object at pointer, PACKAGE = "RProtoBuf" )
+ } )
+
+ setGeneric( "default_value", function(object ){
+ standardGeneric( "default_value" )
+ } )
+ setMethod( "default_value", "FieldDescriptor", function(object){
+- .Call( "FieldDescriptor_default_value", object at pointer, PACKAGE = "RProtoBuf" )
++ .Call( "FieldDescriptor__default_value", object at pointer, PACKAGE = "RProtoBuf" )
+ } )
+
+
+@@ -116,10 +116,9 @@
+ standardGeneric( "message_type" )
+ } )
+ setMethod( "message_type", "FieldDescriptor", function(object){
+- .Call( "FieldDescriptor_message_type", object at pointer, PACKAGE = "RProtoBuf" )
++ .Call( "FieldDescriptor__message_type", object at pointer, PACKAGE = "RProtoBuf" )
+ } )
+
+ setMethod( "enum_type", c( object = "FieldDescriptor", index = "missing", name = "missing"), function(object){
+- .Call( "FieldDescriptor_enum_type", object at pointer, PACKAGE = "RProtoBuf" )
++ .Call( "FieldDescriptor__enum_type", object at pointer, PACKAGE = "RProtoBuf" )
+ } )
+-
Added: patches/patch_by_Murray_rprotobuf_r471-2.diff
===================================================================
--- patches/patch_by_Murray_rprotobuf_r471-2.diff (rev 0)
+++ patches/patch_by_Murray_rprotobuf_r471-2.diff 2012-08-09 12:09:38 UTC (rev 472)
@@ -0,0 +1,54 @@
+Index: src/mutators.cpp
+===================================================================
+--- src/mutators.cpp (revision 471)
++++ src/mutators.cpp (working copy)
+@@ -151,10 +151,22 @@
+ bool GET_bool( SEXP x, int index ){
+ switch( TYPEOF(x) ){
+ case INTSXP:
++ if (INTEGER(x)[index] == R_NaInt) {
++ throwException( "NA boolean values not supported by RProtoBuf",
++ "CastException" ) ;
++ }
+ return( (bool)INTEGER(x)[index] );
+ case REALSXP:
++ if (REAL(x)[index] == R_NaReal) {
++ throwException( "NA boolean values not supported by RProtoBuf",
++ "CastException" ) ;
++ }
+ return( (bool)REAL(x)[index] );
+ case LGLSXP:
++ if (LOGICAL(x)[index] == NA_LOGICAL) {
++ throwException( "NA boolean values not supported by RProtoBuf",
++ "CastException" ) ;
++ }
+ return( (bool)LOGICAL(x)[index] );
+ case RAWSXP:
+ return( (bool)RAW(x)[index] ) ;
+Index: inst/unitTests/runit.golden.message.R
+===================================================================
+--- inst/unitTests/runit.golden.message.R (revision 471)
++++ inst/unitTests/runit.golden.message.R (working copy)
+@@ -60,9 +60,18 @@
+ test <- new(protobuf_unittest.TestAllTypes)
+ test$add("repeated_int32", c(1:5))
+ checkEquals(test$repeated_int32, c(1:5))
++}
+
+- # Prior to RProtoBuf v0.2.5, this was not handled properly.
+- test.2 <- new(protobuf_unittest.TestAllTypes,
+- repeated_string=c("foo", "bar"))
+- checkEquals(test.2$repeated_string, c("foo", "bar"))
++test.repeated.bools <- function() {
++ test <- new(protobuf_unittest.TestAllTypes)
++ test$add("repeated_bool", c(TRUE, FALSE))
++ checkEquals(test$repeated_bool, c(TRUE, FALSE))
++
++ test$add("repeated_bool", as.integer(c(TRUE, FALSE)))
++ test$add("repeated_bool", as.numeric(c(TRUE, FALSE)))
++
++ checkEquals(test$repeated_bool, rep(c(TRUE, FALSE), 3))
++
++ # Verify that we don't silently cast NA into TRUE or FALSE.
++ checkException(test$add("repeated_bool"), c(TRUE, FALSE, NA))
+ }
More information about the Rprotobuf-commits
mailing list