[Rcpp-commits] r3249 - in pkg/Rcpp: . inst inst/include inst/include/Rcpp inst/include/Rcpp/int64 inst/include/Rcpp/internal inst/include/Rcpp/traits src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Oct 31 19:51:17 CET 2011


Author: romain
Date: 2011-10-31 19:51:17 +0100 (Mon, 31 Oct 2011)
New Revision: 3249

Added:
   pkg/Rcpp/inst/include/Rcpp/int64/
   pkg/Rcpp/inst/include/Rcpp/int64/LongVector.h
   pkg/Rcpp/inst/include/Rcpp/int64/get_bits.h
   pkg/Rcpp/inst/include/Rcpp/int64/get_class.h
   pkg/Rcpp/inst/include/Rcpp/int64/get_long.h
   pkg/Rcpp/inst/include/Rcpp/int64/int64_lite.h
   pkg/Rcpp/inst/include/Rcpp/int64/new_long.h
   pkg/Rcpp/inst/include/Rcpp/traits/or.h
   pkg/Rcpp/src/int64_lite.cpp
Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/DESCRIPTION
   pkg/Rcpp/inst/NEWS
   pkg/Rcpp/inst/include/Rcpp/internal/wrap.h
   pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h
   pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h
   pkg/Rcpp/inst/include/RcppCommon.h
Log:
modifications to be able to wrap 64 bit integer types and containers of them

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2011-10-30 17:34:41 UTC (rev 3248)
+++ pkg/Rcpp/ChangeLog	2011-10-31 18:51:17 UTC (rev 3249)
@@ -1,3 +1,11 @@
+2011-10-31  Romain Francois  <romain at r-enthusiasts.com>
+
+    * include/Rcpp/int64/int64_lite.h: handling int64_t and uint64_t types, 
+    based on the int64 package
+    * include/Rcpp/internal/wrap.h: new dispatch layers to handle int64_t, 
+    uint64_t and containers of these
+    * DESCRIPTION: new depending on int64
+
 2011-10-25  Dirk Eddelbuettel  <edd at debian.org>
 
 	* src/Rostream.cpp: Patch by Jelmer Ypma which adds a new device

Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION	2011-10-30 17:34:41 UTC (rev 3248)
+++ pkg/Rcpp/DESCRIPTION	2011-10-31 18:51:17 UTC (rev 3249)
@@ -1,6 +1,6 @@
 Package: Rcpp
 Title: Seamless R and C++ Integration
-Version: 0.9.7.1
+Version: 0.9.7.2
 Date: $Date$
 Author: Dirk Eddelbuettel and Romain Francois, 
  with contributions by Douglas Bates and John Chambers
@@ -38,7 +38,7 @@
  been factored out of Rcpp into the package RcppClassic and it is still
  available for code relying on this interface. New development should use 
  this package instead.
-Depends: R (>= 2.12.0), methods
+Depends: R (>= 2.12.0), methods, int64
 Suggests: RUnit, inline, rbenchmark
 URL: http://dirk.eddelbuettel.com/code/rcpp.html, http://romainfrancois.blog.free.fr/index.php?category/R-package/Rcpp
 License: GPL (>= 2)

Modified: pkg/Rcpp/inst/NEWS
===================================================================
--- pkg/Rcpp/inst/NEWS	2011-10-30 17:34:41 UTC (rev 3248)
+++ pkg/Rcpp/inst/NEWS	2011-10-31 18:51:17 UTC (rev 3249)
@@ -3,6 +3,10 @@
     o   Applied patch by Jelmer Ypma which adds an output stream class
     	'Rcout' not unlike std::cout, but implemented via Rprintf to
     	cooperate with R and its output buffering.
+    	
+    o   wrap now handles 64 bit integer types (int64_t, uint64_t) and containers
+        of them. This work has been sponsored by the Google Open Source
+        Programs Office. 
 
 0.9.7   2011-09-29
 

Added: pkg/Rcpp/inst/include/Rcpp/int64/LongVector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/int64/LongVector.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/int64/LongVector.h	2011-10-31 18:51:17 UTC (rev 3249)
@@ -0,0 +1,96 @@
+// LongVector.h : 64 bit integers
+//
+// Copyright (C) 2011 Romain Francois and Dirk Eddelbuettel
+// Copyright (C) 2011 Google Inc.  All rights reserved.
+//
+// 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__int64__LongVector_h
+#define Rcpp__int64__LongVector_h
+
+namespace Rcpp{
+    namespace int64{
+
+template <class LONG>
+    class LongVector {
+    private :
+        SEXP data ;
+        
+    public:
+        LongVector(SEXP x) : data(x) {
+            R_PreserveObject(data) ;   
+        }
+        
+        operator SEXP(){ 
+            std::string klass = get_class<LONG>() ;
+            SEXP res = PROTECT( 
+                R_do_slot_assign( 
+                    R_do_new_object( R_do_MAKE_CLASS( klass.c_str() ) ), 
+                    Rf_install(".Data"), 
+                    data ) ) ;
+            UNPROTECT(1) ;
+            return res ;    
+        
+        }
+        
+        LongVector(int n) : data(R_NilValue) {
+            SEXP x = PROTECT( Rf_allocVector( VECSXP, n ) ) ;
+            for( int i=0; i<n; i++){
+                SET_VECTOR_ELT( x, i, Rcpp::int64::int2(0,0) ) ;    
+            }
+            UNPROTECT(1) ; // x
+            data = x ;
+            R_PreserveObject(data) ;
+        }
+        
+        template <typename ITERATOR>
+        LongVector(int n, ITERATOR start, ITERATOR end) : data(R_NilValue) {
+            SEXP x = PROTECT( Rf_allocVector( VECSXP, n ) ) ;
+            int hb, lb ;
+            for( int i=0; i<n; i++, ++start){
+                hb = get_high_bits<LONG>(*start) ;
+                lb = get_low_bits<LONG>(*start) ;
+                SET_VECTOR_ELT( x, i, Rcpp::int64::int2(hb,lb) ) ;    
+            }
+            UNPROTECT(1) ; // x
+            data = x ;
+            R_PreserveObject(data) ;
+        }
+        
+        
+        ~LongVector(){
+            R_ReleaseObject(data) ;   
+        }
+        
+        inline LONG get(int i) const {
+            int* p = INTEGER(VECTOR_ELT(data,i)) ;
+            return Rcpp::int64::get_long<LONG>( p[0], p[1] ) ;
+        }
+        
+        inline void set(int i, LONG x){
+            int* p = INTEGER(VECTOR_ELT(data,i)) ;
+            p[0] = Rcpp::int64::get_high_bits(x) ;
+            p[1] = Rcpp::int64::get_low_bits(x) ;
+        }
+        
+        inline int size() const { return Rf_length(data); }
+        
+    } ;
+
+        
+    }
+}
+#endif

Added: pkg/Rcpp/inst/include/Rcpp/int64/get_bits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/int64/get_bits.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/int64/get_bits.h	2011-10-31 18:51:17 UTC (rev 3249)
@@ -0,0 +1,41 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// get_bits.h : Rcpp R/C++ interface class library -- 
+//
+// Copyright (C) 2011 Romain Francois
+// Copyright (C) 2011 Google Inc.  All rights reserved.
+//
+// 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__int64__get_bits__h
+#define Rcpp__int64__get_bits__h
+
+namespace Rcpp{
+    namespace int64{
+
+template <typename T64>
+inline int get_low_bits( T64 x){
+    return (int)( x & 0x00000000FFFFFFFF ) ;
+}
+
+template <typename T64>
+inline int get_high_bits( T64 x){
+    return (int)( x >> 32 ) ;
+}
+
+    } // namespace int64
+} // namespace Rcpp
+#endif

Added: pkg/Rcpp/inst/include/Rcpp/int64/get_class.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/int64/get_class.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/int64/get_class.h	2011-10-31 18:51:17 UTC (rev 3249)
@@ -0,0 +1,43 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// get_class.h : Rcpp R/C++ interface class library -- 
+//
+// Copyright (C) 2011 Romain Francois
+// Copyright (C) 2011 Google Inc.  All rights reserved.
+//
+// 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__int64__get_class__h
+#define Rcpp__int64__get_class__h
+
+namespace Rcpp{
+    namespace int64{
+
+        template <typename T>
+        inline std::string get_class(){ return "" ; }
+        
+        template <>
+        inline std::string get_class<int64_t>(){
+            return "int64" ;
+        }
+        template <>
+        inline std::string get_class<uint64_t>(){
+            return "uint64" ;
+        }
+                  
+    } // namespace int64
+} // namespace Rcpp
+#endif

Added: pkg/Rcpp/inst/include/Rcpp/int64/get_long.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/int64/get_long.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/int64/get_long.h	2011-10-31 18:51:17 UTC (rev 3249)
@@ -0,0 +1,36 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// get_long.h : Rcpp R/C++ interface class library -- 
+//
+// Copyright (C) 2011 Romain Francois
+// Copyright (C) 2011 Google Inc.  All rights reserved.
+//
+// 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__int64__get_long__h
+#define Rcpp__int64__get_long__h
+
+namespace Rcpp{
+    namespace int64{
+
+template <typename T>
+inline T get_long( int highbits, int lowbits ){
+    return ( ( (T) (unsigned int)highbits ) << 32 ) | ( (T) (unsigned int)lowbits ) ;    
+}
+
+    } // namespace int64
+} // namespace Rcpp
+#endif

Added: pkg/Rcpp/inst/include/Rcpp/int64/int64_lite.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/int64/int64_lite.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/int64/int64_lite.h	2011-10-31 18:51:17 UTC (rev 3249)
@@ -0,0 +1,38 @@
+// int64_lite.h : 64 bit integers
+//
+// Copyright (C) 2011 Romain Francois and Dirk Eddelbuettel
+// Copyright (C) 2011 Google Inc.  All rights reserved.
+//
+// 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 int64__lite_h
+#define int64__lite_h
+
+namespace Rcpp{
+    namespace int64{
+        SEXP int2(int,int); 
+        
+        template <typename LONG> class LongVector ;
+    }
+}    
+
+#include <Rcpp/int64/get_class.h>
+#include <Rcpp/int64/get_long.h>
+#include <Rcpp/int64/get_bits.h>
+#include <Rcpp/int64/new_long.h>
+#include <Rcpp/int64/LongVector.h>
+
+#endif

Added: pkg/Rcpp/inst/include/Rcpp/int64/new_long.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/int64/new_long.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/int64/new_long.h	2011-10-31 18:51:17 UTC (rev 3249)
@@ -0,0 +1,45 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// new_long.h : Rcpp R/C++ interface class library -- 
+//
+// Copyright (C) 2011 Romain Francois
+// Copyright (C) 2011 Google Inc.  All rights reserved.
+//
+// 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__int64__new_long__h
+#define Rcpp__int64__new_long__h
+
+namespace Rcpp{
+    namespace int64{
+
+        template <typename LONG>
+        SEXP new_long(LONG x){
+            std::string klass = get_class<LONG>() ;
+            int64::LongVector<LONG> y(1) ;
+            y.set(0, x) ;
+            SEXP res = PROTECT( 
+                R_do_slot_assign( 
+                    R_do_new_object( R_do_MAKE_CLASS( klass.c_str() ) ), 
+                    Rf_install(".Data"), 
+                    y ) ) ;
+            UNPROTECT(1) ;
+            return res ;
+        }
+        
+    } // namespace int64
+} // namespace Rcpp
+#endif

Modified: pkg/Rcpp/inst/include/Rcpp/internal/wrap.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/internal/wrap.h	2011-10-30 17:34:41 UTC (rev 3248)
+++ pkg/Rcpp/inst/include/Rcpp/internal/wrap.h	2011-10-31 18:51:17 UTC (rev 3249)
@@ -250,6 +250,12 @@
 		typename ::Rcpp::traits::r_sexptype_needscast<typename T::second_type>() ) ;
 }
 
+template <typename InputIterator, typename T>
+inline SEXP range_wrap_dispatch___impl( InputIterator first, InputIterator last, ::Rcpp::traits::r_type_int64_tag){ 
+	return Rcpp::int64::LongVector<T>( std::distance(first, last), first, last ) ;
+}
+
+
 /**
  * Range based wrap implementation that deals with iterators over
  * pair<const string, U> where U is wrappable. This is the kind of 
@@ -686,6 +692,17 @@
 inline SEXP wrap_dispatch( const T& object, ::Rcpp::traits::wrap_type_unknown_tag ){
 	return wrap_dispatch_unknown_importable( object, typename ::Rcpp::traits::is_importer<T>::type() ) ;
 }
+
+/** 
+ * This is called by wrap when the wrap_type_traits is wrap_type_int64_tag
+ * 
+ * This wraps a single int64
+ */
+template <typename T> 
+inline SEXP wrap_dispatch( const T& object, ::Rcpp::traits::wrap_type_int64_tag ){
+	return Rcpp::int64::new_long<T>( object ) ;
+}
+
 	// }}}
 
 // {{{ wrap a container that is structured in row major order

Added: pkg/Rcpp/inst/include/Rcpp/traits/or.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/or.h	                        (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/traits/or.h	2011-10-31 18:51:17 UTC (rev 3249)
@@ -0,0 +1,34 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+//
+// or.h: Rcpp R/C++ interface class library -- dispatch
+//                                                                      
+// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and 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__traits_or_h
+#define Rcpp__traits_or_h
+
+namespace Rcpp{
+namespace traits{
+	
+template <typename LHS, typename RHS>
+struct or_ : integral_constant<bool,LHS::value | RHS::value>{} ;
+
+}
+}
+
+#endif

Modified: pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h	2011-10-30 17:34:41 UTC (rev 3248)
+++ pkg/Rcpp/inst/include/Rcpp/traits/r_type_traits.h	2011-10-31 18:51:17 UTC (rev 3249)
@@ -59,6 +59,8 @@
  */
 struct r_type_pairstring_generic_tag{} ;
 
+struct r_type_int64_tag{} ;
+
 /**
  * R type trait. Helps wrap.
  */
@@ -129,6 +131,9 @@
 template<> struct r_type_traits< std::pair<const std::string,rcpp_ulong_long_type> >{ typedef r_type_primitive_tag r_category ; } ;
 #endif
 
+template<> struct r_type_traits<int64_t>{ typedef r_type_int64_tag r_category; } ;
+template<> struct r_type_traits<uint64_t>{ typedef r_type_int64_tag r_category ; } ;
+
 } // traits
 } // Rcpp
 

Modified: pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h	2011-10-30 17:34:41 UTC (rev 3248)
+++ pkg/Rcpp/inst/include/Rcpp/traits/wrap_type_traits.h	2011-10-31 18:51:17 UTC (rev 3249)
@@ -37,6 +37,11 @@
 struct wrap_type_unknown_tag{};
 
 /**
+ * int64_t
+ */
+struct wrap_type_int64_tag{};
+
+/**
  * Type trait that helps the dispatch of wrap to the proper method
  *
  * This builds a struct that contains a typedef called wrap_category
@@ -78,6 +83,9 @@
 template <> struct wrap_type_traits<rcpp_ulong_long_type> { typedef wrap_type_primitive_tag wrap_category; } ;
 #endif
 
+template <> struct wrap_type_traits<int64_t> { typedef wrap_type_int64_tag wrap_category; } ;
+template <> struct wrap_type_traits<uint64_t> { typedef wrap_type_int64_tag wrap_category; } ;
+
 } // namespace traits
 } // namespace Rcpp
 #endif

Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h	2011-10-30 17:34:41 UTC (rev 3248)
+++ pkg/Rcpp/inst/include/RcppCommon.h	2011-10-31 18:51:17 UTC (rev 3249)
@@ -43,6 +43,7 @@
 
 #include <Rcpp/config.h>
 #include <Rcpp/macros/unroll.h>
+#include <stdint.h>
 
 void logTxtFunction(const char* file, const int line, const char* expression ) ;
 
@@ -283,6 +284,7 @@
 #include <Rcpp/traits/get_na.h>
 #include <Rcpp/traits/is_trivial.h>
 #include <Rcpp/traits/init_type.h>
+#include <Rcpp/traits/or.h>
 
 #include <Rcpp/traits/is_const.h>
 #include <Rcpp/traits/is_reference.h>
@@ -297,6 +299,7 @@
 #include <Rcpp/internal/r_vector.h>
 #include <Rcpp/r_cast.h>
 
+#include <Rcpp/int64/int64_lite.h>
 #include <Rcpp/internal/wrap_forward.h>
 
 #include <Rcpp/Date_forward.h>

Added: pkg/Rcpp/src/int64_lite.cpp
===================================================================
--- pkg/Rcpp/src/int64_lite.cpp	                        (rev 0)
+++ pkg/Rcpp/src/int64_lite.cpp	2011-10-31 18:51:17 UTC (rev 3249)
@@ -0,0 +1,38 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
+//
+// barrier.cpp: Rcpp R/C++ interface class library -- write barrier
+//
+// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2011 Google Inc.  All rights reserved.
+//
+// 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/>.
+
+#include <Rcpp.h>
+
+namespace Rcpp{
+    namespace int64{
+
+        SEXP int2(int x, int y){
+            SEXP res = PROTECT( Rf_allocVector(INTSXP, 2) ) ;
+            int* p = INTEGER(res) ;
+            p[0] = x;
+            p[1] = y ;
+            UNPROTECT(1) ;
+            return res ;
+        }
+        
+    }
+}



More information about the Rcpp-commits mailing list