[Rcpp-commits] r3387 - in pkg/int64: inst/include/int64 src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Nov 18 21:40:58 CET 2011


Author: romain
Date: 2011-11-18 21:40:58 +0100 (Fri, 18 Nov 2011)
New Revision: 3387

Added:
   pkg/int64/inst/include/int64/int2.h
Modified:
   pkg/int64/inst/include/int64/int64.h
   pkg/int64/src/int64.cpp
Log:
trying to allow LinkingTo: int64 so that client packages of int64 don't have to copy the internals of the package

Added: pkg/int64/inst/include/int64/int2.h
===================================================================
--- pkg/int64/inst/include/int64/int2.h	                        (rev 0)
+++ pkg/int64/inst/include/int64/int2.h	2011-11-18 20:40:58 UTC (rev 3387)
@@ -0,0 +1,43 @@
+// routines.h: int64 64 bit integers
+//
+// Copyright (C) 2011 Romain Francois
+// Copyright (C) 2011 Google Inc.  All rights reserved.
+//
+// This file is part of int64.
+//
+// int64 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.
+//
+// int64 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 int64.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef int64_int2_h
+#define int64_int2_h
+
+
+namespace int64{
+    namespace internal{
+        
+        // we only use this for T=int
+        template <typename T>
+        SEXP int2( T x, T y){
+            SEXP res = PROTECT( Rf_allocVector(INTSXP, 2) ) ;
+            int* p = INTEGER(res) ;
+            p[0] = x;
+            p[1] = y ;
+            UNPROTECT(1) ;
+            return res ;
+        }
+        
+    }
+}
+
+
+#endif

Modified: pkg/int64/inst/include/int64/int64.h
===================================================================
--- pkg/int64/inst/include/int64/int64.h	2011-11-18 19:46:03 UTC (rev 3386)
+++ pkg/int64/inst/include/int64/int64.h	2011-11-18 20:40:58 UTC (rev 3387)
@@ -23,12 +23,11 @@
 
 namespace int64{
     namespace internal {
-        SEXP int2(int,int) ;
-        
         bool int64_naflag = false ;
     }
 }
 
+#include <int64/int2.h>
 #include <int64/read_string_forward.h>
 #include <int64/get_long.h>
 #include <int64/get_bits.h>

Modified: pkg/int64/src/int64.cpp
===================================================================
--- pkg/int64/src/int64.cpp	2011-11-18 19:46:03 UTC (rev 3386)
+++ pkg/int64/src/int64.cpp	2011-11-18 20:40:58 UTC (rev 3387)
@@ -18,6 +18,8 @@
 // You should have received a copy of the GNU General Public License
 // along with int64.  If not, see <http://www.gnu.org/licenses/>.
 
+#define BUILDING_INT64
+
 #include <int64.h>
 #include <limits>
 
@@ -27,14 +29,6 @@
         
         
         /* tool to make an int vector with two ints */
-        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 ;
-        }
         
         SEXP int64_format_binary__standard(SEXP x){
             int n = Rf_length(x) ;



More information about the Rcpp-commits mailing list