[Rprotobuf-commits] r721 - in pkg: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Jan 5 04:11:30 CET 2014
Author: murray
Date: 2014-01-05 04:11:26 +0100 (Sun, 05 Jan 2014)
New Revision: 721
Modified:
pkg/ChangeLog
pkg/R/00classes.R
pkg/R/wrapper_CodedInputStream.R
Log:
Get ReadRaw() and ReadString() working with ArrayInputStream /
ZeroCopyInputStream.
Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog 2014-01-05 02:40:05 UTC (rev 720)
+++ pkg/ChangeLog 2014-01-05 03:11:26 UTC (rev 721)
@@ -1,5 +1,10 @@
2014-01-04 Murray Stokely <mstokely at google.com>
+ * R/wrapper_CodedInputStream.R: Accept numeric size arguments for
+ ReadRaw and ReadString to make this more user friendly for
+ interactive use by calling as.integer() as needed.
+ * R/00classes.R (P): Add missing object prameters in
+ ZeroCopyInputStream calls to ReadRaw and ReadString.
* inst/unitTests/data/encoding.proto: Add example messages used in
the encoding documentation.
* inst/unitTests/runit.serialize.R (test.encoding): Add tests
Modified: pkg/R/00classes.R
===================================================================
--- pkg/R/00classes.R 2014-01-05 02:40:05 UTC (rev 720)
+++ pkg/R/00classes.R 2014-01-05 03:11:26 UTC (rev 721)
@@ -344,8 +344,8 @@
"BackUp" = function(...) BackUp(x, ...),
# CodedInputStream related
- "ReadRaw" = function(...) ReadRaw(...),
- "ReadString" = function(...) ReadString(...),
+ "ReadRaw" = function(...) ReadRaw(x, ...),
+ "ReadString" = function(...) ReadString(x, ...),
"ReadVarint32"= function() ReadVarint32(x),
"ReadVarint64" = function() ReadVarint64(x),
"ReadLittleEndian32" = function() ReadLittleEndian32(x),
Modified: pkg/R/wrapper_CodedInputStream.R
===================================================================
--- pkg/R/wrapper_CodedInputStream.R 2014-01-05 02:40:05 UTC (rev 720)
+++ pkg/R/wrapper_CodedInputStream.R 2014-01-05 03:11:26 UTC (rev 721)
@@ -5,6 +5,15 @@
setMethod( "ReadRaw", c( object="ZeroCopyInputStream", size = "integer" ), function(object, size){
.Call( "ZeroCopyInputStream_ReadRaw", object at pointer, size, PACKAGE = "RProtoBuf" )
} )
+setMethod("ReadRaw", c( object="ZeroCopyInputStream", size = "numeric" ),
+ function(object, size) {
+ if (size %% 1 == 0) {
+ .Call( "ZeroCopyInputStream_ReadRaw", object at pointer, as.integer(size),
+ PACKAGE = "RProtoBuf" )
+ } else {
+ stop("Size must be a whole number.")
+ }
+} )
setGeneric( "ReadString", function(object, size ){
standardGeneric( "ReadString" )
@@ -12,6 +21,15 @@
setMethod( "ReadString", c( object="ZeroCopyInputStream", size = "integer" ), function(object, size){
.Call( "ZeroCopyInputStream_ReadString", object at pointer, size, PACKAGE = "RProtoBuf" )
} )
+setMethod("ReadString", c( object="ZeroCopyInputStream", size = "numeric" ),
+ function(object, size) {
+ if (size %% 1 == 0) {
+ .Call("ZeroCopyInputStream_ReadString", object at pointer, as.integer(size),
+ PACKAGE = "RProtoBuf" )
+ } else {
+ stop("Size must be a whole number.")
+ }
+} )
setGeneric( "ReadVarint32", function(object){
standardGeneric( "ReadVarint32" )
@@ -40,4 +58,3 @@
setMethod( "ReadVarint64", c( object="ZeroCopyInputStream"), function(object){
.Call( "ZeroCopyInputStream_ReadVarint64", object at pointer, PACKAGE = "RProtoBuf" )
} )
-
More information about the Rprotobuf-commits
mailing list