[Rprotobuf-commits] r797 - in pkg: . src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jan 19 23:14:27 CET 2014


Author: edd
Date: 2014-01-19 23:14:27 +0100 (Sun, 19 Jan 2014)
New Revision: 797

Modified:
   pkg/ChangeLog
   pkg/src/S4_classes.h
Log:
Adapt to S4 access function renaming in Rcpp 0.10.7 and later, with special thanks to Kevin Ushey


Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2014-01-18 04:38:42 UTC (rev 796)
+++ pkg/ChangeLog	2014-01-19 22:14:27 UTC (rev 797)
@@ -1,3 +1,8 @@
+2014-01-19  Dirk Eddelbuettel  <edd at debian.org>
+
+	* src/S4_classes.h: Adapt to S4 access function renaming in Rcpp
+	0.10.7 and later, with special thanks to Kevin Ushey
+
 2014-01-13  Murray Stokely  <mstokely at google.com>
 
 	* inst/unitTests/runit.int64.R (test.int64): Skip this test with a

Modified: pkg/src/S4_classes.h
===================================================================
--- pkg/src/S4_classes.h	2014-01-18 04:38:42 UTC (rev 796)
+++ pkg/src/S4_classes.h	2014-01-19 22:14:27 UTC (rev 797)
@@ -1,6 +1,6 @@
 // S4_classes.h: R/C++ interface class library
 //
-// Copyright (C) 2010 - 2011  Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2014  Dirk Eddelbuettel and Romain Francois
 //
 // This file is part of RProtoBuf.
 //
@@ -20,8 +20,23 @@
 #ifndef RPROTOBUF_S4CLASSES_H
 #define RPROTOBUF_S4CLASSES_H
 
+//1. Place using Rcpp::S4; somewhere in the top of S4_classes.h in the
+//src directory (so S4 is looked up in the right place),
+//2. Replace setSEXP with set__, and asSexp with get__.
+
 namespace rprotobuf {
 
+// deal with Rcpp API changes
+#if defined(RCPP_VERSION) && RCPP_VERSION <= Rcpp_Version(0,10,6)
+    #define SetSexp setSEXP
+    #define AsSexp  asSexp
+#else
+    #define SetSexp set__
+    #define AsSexp  get__
+#endif
+
+using Rcpp::S4;
+
 class ZeroCopyInputStreamWrapper;
 class ZeroCopyOutputStreamWrapper;
 
@@ -35,13 +50,13 @@
             slot("name") = d->name();
             slot("full_name") = d->full_name();
         } else {
-            setSEXP(R_NilValue);
+            SetSexp(R_NilValue);
         }
     }
 
-    S4_EnumValueDescriptor(const S4_EnumValueDescriptor& other) : S4() { setSEXP(other.asSexp()); }
+    S4_EnumValueDescriptor(const S4_EnumValueDescriptor& other) : S4() { SetSexp(other.AsSexp()); }
     S4_EnumValueDescriptor& operator=(const S4_EnumValueDescriptor& other) {
-        setSEXP(other.asSexp());
+        SetSexp(other.AsSexp());
         return *this;
     }
 };
@@ -57,9 +72,9 @@
         }
     }
 
-    S4_Descriptor(const S4_Descriptor& other) : S4() { setSEXP(other.asSexp()); }
+    S4_Descriptor(const S4_Descriptor& other) : S4() { SetSexp(other.AsSexp()); }
     S4_Descriptor& operator=(const S4_Descriptor& other) {
-        setSEXP(other.asSexp());
+        SetSexp(other.AsSexp());
         return *this;
     }
 };
@@ -78,9 +93,9 @@
         }
     }
 
-    S4_FileDescriptor(const S4_FileDescriptor& other) : S4() { setSEXP(other.asSexp()); }
+    S4_FileDescriptor(const S4_FileDescriptor& other) : S4() { SetSexp(other.AsSexp()); }
     S4_FileDescriptor& operator=(const S4_FileDescriptor& other) {
-        setSEXP(other.asSexp());
+        SetSexp(other.AsSexp());
         return *this;
     }
 };
@@ -95,9 +110,9 @@
         slot("type") = d->containing_type()->full_name();
     }
 
-    S4_FieldDescriptor(const S4_FieldDescriptor& other) : S4() { setSEXP(other.asSexp()); }
+    S4_FieldDescriptor(const S4_FieldDescriptor& other) : S4() { SetSexp(other.AsSexp()); }
     S4_FieldDescriptor& operator=(const S4_FieldDescriptor& other) {
-        setSEXP(other.asSexp());
+        SetSexp(other.AsSexp());
         return *this;
     }
 };
@@ -109,9 +124,9 @@
             Rcpp::XPtr<GPB::ServiceDescriptor>(const_cast<GPB::ServiceDescriptor*>(d), false);
     }
 
-    S4_ServiceDescriptor(const S4_ServiceDescriptor& other) : S4() { setSEXP(other.asSexp()); }
+    S4_ServiceDescriptor(const S4_ServiceDescriptor& other) : S4() { SetSexp(other.AsSexp()); }
     S4_ServiceDescriptor& operator=(const S4_ServiceDescriptor& other) {
-        setSEXP(other.asSexp());
+        SetSexp(other.AsSexp());
         return *this;
     }
 };
@@ -123,9 +138,9 @@
             Rcpp::XPtr<GPB::MethodDescriptor>(const_cast<GPB::MethodDescriptor*>(d), false);
     }
 
-    S4_MethodDescriptor(const S4_MethodDescriptor& other) : S4() { setSEXP(other.asSexp()); }
+    S4_MethodDescriptor(const S4_MethodDescriptor& other) : S4() { SetSexp(other.AsSexp()); }
     S4_MethodDescriptor& operator=(const S4_MethodDescriptor& other) {
-        setSEXP(other.asSexp());
+        SetSexp(other.AsSexp());
         return *this;
     }
 };
@@ -149,9 +164,9 @@
         }
     }
 
-    S4_EnumDescriptor(const S4_EnumDescriptor& other) : S4() { setSEXP(other.asSexp()); }
+    S4_EnumDescriptor(const S4_EnumDescriptor& other) : S4() { SetSexp(other.AsSexp()); }
     S4_EnumDescriptor& operator=(const S4_EnumDescriptor& other) {
-        setSEXP(other.asSexp());
+        SetSexp(other.AsSexp());
         return *this;
     }
 };
@@ -162,9 +177,9 @@
         slot("pointer") = Rcpp::XPtr<GPB::Message>(const_cast<GPB::Message*>(d), true);
         slot("type") = d->GetDescriptor()->full_name();
     }
-    S4_Message(const S4_Message& other) : S4() { setSEXP(other.asSexp()); }
+    S4_Message(const S4_Message& other) : S4() { SetSexp(other.AsSexp()); }
     S4_Message& operator=(const S4_Message& other) {
-        setSEXP(other.asSexp());
+        SetSexp(other.AsSexp());
         return *this;
     }
 };
@@ -183,9 +198,9 @@
         slot("pointer") = wrapper;
     }
 
-    S4_ArrayOutputStream(const S4_ArrayOutputStream& other) { setSEXP(other.asSexp()); }
+    S4_ArrayOutputStream(const S4_ArrayOutputStream& other) { SetSexp(other.AsSexp()); }
     S4_ArrayOutputStream& operator=(const S4_ArrayOutputStream& other) {
-        setSEXP(other.asSexp());
+        SetSexp(other.AsSexp());
         return *this;
     }
 };
@@ -201,6 +216,9 @@
     }
 };
 
+   #undef SetSexp
+   #undef AsSexp
+
 }  // namespace rprotobuf
 
 #endif



More information about the Rprotobuf-commits mailing list