[Rcpp-commits] r4572 - in pkg/Rcpp: . inst/include inst/include/Rcpp inst/include/Rcpp/api/meat inst/include/Rcpp/protection inst/include/Rcpp/vector

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Oct 14 19:58:23 CEST 2013


Author: romain
Date: 2013-10-14 19:58:22 +0200 (Mon, 14 Oct 2013)
New Revision: 4572

Added:
   pkg/Rcpp/inst/include/Rcpp/api/meat/protection.h
   pkg/Rcpp/inst/include/Rcpp/protection/
   pkg/Rcpp/inst/include/Rcpp/protection/Armor.h
   pkg/Rcpp/inst/include/Rcpp/protection/Shelter.h
   pkg/Rcpp/inst/include/Rcpp/protection/Shield.h
   pkg/Rcpp/inst/include/Rcpp/protection/protection.h
Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/DESCRIPTION
   pkg/Rcpp/inst/include/Rcpp/api/meat/meat.h
   pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
   pkg/Rcpp/inst/include/RcppCommon.h
Log:
added Shield Armor and Shelter

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2013-10-14 17:50:40 UTC (rev 4571)
+++ pkg/Rcpp/ChangeLog	2013-10-14 17:58:22 UTC (rev 4572)
@@ -1,3 +1,8 @@
+2013-10-14 Romain Francois <romain at r-enthusiasts.com>
+	
+	* inst/include/Rcpp/protection/protection.h: added Shield/Shelter/Armor
+	* DESCRIPTION: bump to version 0.10.5.3
+
 2013-10-12  Dirk Eddelbuettel  <edd at debian.org>
 
 	* DESCRIPTION (Depends): Rolled Depends: on R to "R (>= 3.0.0)" as

Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION	2013-10-14 17:50:40 UTC (rev 4571)
+++ pkg/Rcpp/DESCRIPTION	2013-10-14 17:58:22 UTC (rev 4572)
@@ -1,6 +1,6 @@
 Package: Rcpp
 Title: Seamless R and C++ Integration
-Version: 0.10.5.2
+Version: 0.10.5.3
 Date: $Date$
 Author: Dirk Eddelbuettel and Romain Francois, with contributions 
  by Douglas Bates, John Chambers and JJ Allaire

Modified: pkg/Rcpp/inst/include/Rcpp/api/meat/meat.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/api/meat/meat.h	2013-10-14 17:50:40 UTC (rev 4571)
+++ pkg/Rcpp/inst/include/Rcpp/api/meat/meat.h	2013-10-14 17:58:22 UTC (rev 4572)
@@ -30,6 +30,7 @@
 #include <Rcpp/api/meat/Reference.h>
 #include <Rcpp/api/meat/is.h>
 #include <Rcpp/api/meat/export.h>
+#include <Rcpp/api/meat/protection.h>
 #include <Rcpp/api/meat/wrap.h>
 
 #endif

Added: pkg/Rcpp/inst/include/Rcpp/api/meat/protection.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/api/meat/protection.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/api/meat/protection.h	2013-10-14 17:58:22 UTC (rev 4572)
@@ -0,0 +1,43 @@
+// Copyright (C) 2013    Romain Francois
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef Rcpp_protection_meat_H
+#define Rcpp_protection_meat_H
+      
+namespace Rcpp{
+
+    template <typename T>
+    template <typename U>
+    Armor<T>::Armor( U x ) : data() {
+        init( wrap(x) ) ;
+    }       
+        
+    template <typename T>
+    template <typename U>
+    inline Armor<T>& Armor<T>::operator=( U x ){
+        REPROTECT(data = wrap(x), index) ;
+        return *this ;
+    }
+         
+    template <typename T>
+    template <typename U>
+    inline Shield<T>::operator U() const { 
+        return as<U>(t) ; 
+    }
+}
+
+#endif

Added: pkg/Rcpp/inst/include/Rcpp/protection/Armor.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/protection/Armor.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/protection/Armor.h	2013-10-14 17:58:22 UTC (rev 4572)
@@ -0,0 +1,58 @@
+// Copyright (C) 2013    Romain Francois
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
+        
+#ifndef Rcpp_protection_Armor_H
+#define Rcpp_protection_Armor_H
+
+namespace Rcpp {
+    
+    template <typename T>
+    class Armor {
+    public:
+        
+        Armor() : data(){
+            init(R_NilValue) ;    
+        }
+        
+        template <typename U> Armor( U x );
+        
+        inline operator SEXP(){
+            return data ;
+        }
+              
+        template <typename U>
+        inline Armor& operator=( U x ) ;
+        
+        ~Armor(){
+            UNPROTECT(1) ;
+        }
+        
+    private:
+        void init(SEXP x){
+           PROTECT_WITH_INDEX( data = x, &index ) ;     
+        }
+        
+        SEXP data ;
+        PROTECT_INDEX index ;
+        
+        // not defined on purpose
+        Armor(const Armor&) ;
+        Armor& operator=(const Armor&) ; 
+    } ;
+}
+
+#endif

Added: pkg/Rcpp/inst/include/Rcpp/protection/Shelter.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/protection/Shelter.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/protection/Shelter.h	2013-10-14 17:58:22 UTC (rev 4572)
@@ -0,0 +1,47 @@
+// Copyright (C) 2013    Romain Francois
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef Rcpp_protection_Shelter_H
+#define Rcpp_protection_Shelter_H
+
+namespace Rcpp {
+    
+    template <class T>
+    class Shelter {
+    public:
+        Shelter() : nprotected(0){}
+        
+        inline SEXP operator()(SEXP x){
+            nprotected++;             
+            return PROTECT(x) ;
+        }
+        
+        ~Shelter(){
+            UNPROTECT(nprotected) ;
+            nprotected = 0 ;
+        }
+        
+    private:
+        int nprotected ;
+          
+        // not defined on purpose
+        Shelter(const Shelter&) ;
+        Shelter& operator=(const Shelter&) ; 
+    } ;
+}
+
+#endif

Added: pkg/Rcpp/inst/include/Rcpp/protection/Shield.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/protection/Shield.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/protection/Shield.h	2013-10-14 17:58:22 UTC (rev 4572)
@@ -0,0 +1,44 @@
+// Copyright (C) 2013    Romain Francois
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef Rcpp_protection_Shield_H
+#define Rcpp_protection_Shield_H
+
+namespace Rcpp {
+    
+    template <typename T>
+    class Shield{
+    public:
+        Shield( SEXP t_) : t(PROTECT(t_)){}
+        ~Shield(){
+            UNPROTECT(1) ;    
+        }
+        
+        template <typename U>
+        inline operator U() const  ;
+        
+    private:  
+        // not defined on purpose
+        Shield( const Shield& ) ;
+        Shield& operator=( const Shield& ) ;
+    
+        SEXP t ;
+    } ;
+    
+}
+
+#endif

Added: pkg/Rcpp/inst/include/Rcpp/protection/protection.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/protection/protection.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/protection/protection.h	2013-10-14 17:58:22 UTC (rev 4572)
@@ -0,0 +1,25 @@
+// Copyright (C) 2013    Romain Francois
+//
+// This file is part of Rcpp.
+//
+// Rcpp is free software: you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// Rcpp is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef Rcpp_protection_protection_H
+#define Rcpp_protection_protection_H
+
+#include <Rcpp/protection/Shield.h>
+#include <Rcpp/protection/Shelter.h>
+#include <Rcpp/protection/Armor.h>
+
+#endif

Modified: pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2013-10-14 17:50:40 UTC (rev 4571)
+++ pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2013-10-14 17:58:22 UTC (rev 4572)
@@ -88,7 +88,7 @@
         update_vector();
     }
     Vector( const char* st ) : RObject( internal::vector_from_string<RTYPE>(st) ){
-        RCPP_DEBUG_2( "Vector<%d>( const char* = %s )", RTYPE, st.c_str() )
+        RCPP_DEBUG_2( "Vector<%d>( const char* = %s )", RTYPE, st )
         update_vector();
     }
 	

Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h	2013-10-14 17:50:40 UTC (rev 4571)
+++ pkg/Rcpp/inst/include/RcppCommon.h	2013-10-14 17:58:22 UTC (rev 4572)
@@ -82,6 +82,7 @@
 #include <Rcpp/sprintf.h>
 
 
+#include <Rcpp/protection/protection.h>
 #include <Rcpp/lang.h>
 #include <Rcpp/complex.h>
 #include <Rcpp/barrier.h>



More information about the Rcpp-commits mailing list