[Rprotobuf-commits] r678 - pkg/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Dec 31 21:12:27 CET 2013
Author: murray
Date: 2013-12-31 21:12:26 +0100 (Tue, 31 Dec 2013)
New Revision: 678
Modified:
pkg/src/lookup.cpp
Log:
Replace a call to Rf_error with Rcpp exception handling and BEGIN/END_RCPP.
Add an 'unused_' prefix to arguments that we don't use.
Modified: pkg/src/lookup.cpp
===================================================================
--- pkg/src/lookup.cpp 2013-12-31 20:10:22 UTC (rev 677)
+++ pkg/src/lookup.cpp 2013-12-31 20:12:26 UTC (rev 678)
@@ -135,9 +135,9 @@
/**
* Does nothing. Not applicable
*/
-int rProtoBufTable_remove(const char *const name, R_ObjectTable *tb) {
+int rProtoBufTable_remove(const char *const unused_name, R_ObjectTable *unused_tb) {
#ifdef LOOKUP_DEBUG
- Rprintf(" >> rProtoBufTable_remove( %s) \n", name);
+ Rprintf(" >> rProtoBufTable_remove( %s) \n", unused_name);
#endif
Rf_error("cannot remove from protobuf descriptor pool");
return (0); // make -Wall happy
@@ -151,7 +151,7 @@
* @param tb lookup table
* @return allways _FALSE_ (for now)
*/
-Rboolean rProtoBufTable_canCache(const char *const name, R_ObjectTable *tb) {
+Rboolean rProtoBufTable_canCache(const char *const unused_name, R_ObjectTable *unused_tb) {
#ifdef LOOKUP_DEBUG
Rprintf(" >> rProtoBufTable_canCache\n");
#endif
@@ -165,9 +165,10 @@
* NULL to indicate assign is not possible on this lookup table
* without giving such a hard error.
*/
-SEXP rProtoBufTable_assign(const char *const name, SEXP value, R_ObjectTable *tb) {
+SEXP rProtoBufTable_assign(const char *const unused_name, SEXP unused_value,
+ R_ObjectTable *unused_tb) {
#ifdef LOOKUP_DEBUG
- Rprintf(" >> rProtoBufTable_assign( %s ) \n", name);
+ Rprintf(" >> rProtoBufTable_assign( %s ) \n", unused_name);
#endif
return (R_NilValue); // make -Wall happy
}
@@ -190,7 +191,8 @@
return (objects);
}
-SEXP newProtocolBufferLookup(SEXP possexp) {
+RcppExport SEXP newProtocolBufferLookup(SEXP possexp) {
+ BEGIN_RCPP
#ifdef LOOKUP_DEBUG
Rprintf("<newProtocolBufferLookup>\n");
#endif
@@ -199,7 +201,7 @@
SEXP val, klass;
tb = (R_ObjectTable *)malloc(sizeof(R_ObjectTable));
- if (!tb) Rf_error("cannot allocate space for an internal R object table");
+ if (!tb) throw Rcpp::exception("cannot allocate space for an internal R object table");
tb->type = RPROTOBUF_LOOKUP; /* FIXME: not sure what this should be */
tb->cachedNames = NULL;
@@ -229,7 +231,9 @@
int pos = Rcpp::as<int>(possexp);
fun(val, Rcpp::Named("pos") = pos, Rcpp::Named("name") = "RProtoBuf:DescriptorPool");
+ // TODO(mstokely): Somewhere we should deallocate tb? If package is unattached?
return (val);
+ END_RCPP
}
} // namespace rprotobuf
More information about the Rprotobuf-commits
mailing list