[Rprotobuf-commits] r717 - pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 5 00:40:19 CET 2014


Author: murray
Date: 2014-01-05 00:40:18 +0100 (Sun, 05 Jan 2014)
New Revision: 717

Modified:
   pkg/src/wrapper_ZeroCopyInputStream.cpp
Log:
Add necessary BEGIN/END_RCPP macros so that we catch exceptions and
don't crash R.  This doesn't work currently, but now I see what it is
for and it seems useful.  Next() always throws the range_error when on
an arrayinputobject instantiated with raw(0:10) as in the commented
out examples from the man page.  Will try to get that working.



Modified: pkg/src/wrapper_ZeroCopyInputStream.cpp
===================================================================
--- pkg/src/wrapper_ZeroCopyInputStream.cpp	2014-01-04 23:11:07 UTC (rev 716)
+++ pkg/src/wrapper_ZeroCopyInputStream.cpp	2014-01-04 23:40:18 UTC (rev 717)
@@ -4,6 +4,7 @@
 namespace rprotobuf {
 
 SEXP ZeroCopyInputStream_Next(SEXP xp) {
+    BEGIN_RCPP
     GPB::io::ZeroCopyInputStream* stream = GET_ZCIS(xp);
     int s = 0;
     const void* in;
@@ -15,9 +16,11 @@
         result.assign(reinterpret_cast<const Rbyte*>(in), reinterpret_cast<const Rbyte*>(in) + s);
     }
     return result;
+    END_RCPP
 }
 
 SEXP ZeroCopyInputStream_BackUp(SEXP xp, SEXP size) {
+    BEGIN_RCPP
     GPB::io::ZeroCopyInputStream* stream = GET_ZCIS(xp);
     int s = GET_int(size, 0);
     if (s <= 0) {
@@ -25,17 +28,22 @@
     }
     stream->BackUp(s);
     return R_NilValue;
+    END_RCPP
 }
 
 SEXP ZeroCopyInputStream_Skip(SEXP xp, SEXP size) {
+    BEGIN_RCPP
     GPB::io::ZeroCopyInputStream* stream = GET_ZCIS(xp);
     int s = GET_int(size, 0);
     bool res = stream->Skip(s);
     return (Rf_ScalarLogical(res ? _TRUE_ : _FALSE_));
+    END_RCPP
 }
 
 SEXP ZeroCopyInputStream_ByteCount(SEXP xp) {
+    BEGIN_RCPP
     GPB::io::ZeroCopyInputStream* stream = GET_ZCIS(xp);
     return (Rf_ScalarReal((double)stream->ByteCount()));
+    END_RCPP
 }
 }



More information about the Rprotobuf-commits mailing list