[Rcpp-commits] r3829 - in pkg/Rcpp: . inst/include inst/include/Rcpp inst/include/Rcpp/module inst/include/Rcpp/traits
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Oct 24 14:44:22 CEST 2012
Author: romain
Date: 2012-10-24 14:44:22 +0200 (Wed, 24 Oct 2012)
New Revision: 3829
Added:
pkg/Rcpp/inst/include/Rcpp/traits/is_pointer.h
pkg/Rcpp/inst/include/Rcpp/traits/un_pointer.h
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/inst/include/Rcpp/config.h
pkg/Rcpp/inst/include/Rcpp/module/Module_generated_get_return_type.h
pkg/Rcpp/inst/include/Rcpp/traits/module_wrap_traits.h
pkg/Rcpp/inst/include/RcppCommon.h
Log:
nicer signatures for methods using pointers
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2012-10-24 06:51:53 UTC (rev 3828)
+++ pkg/Rcpp/ChangeLog 2012-10-24 12:44:22 UTC (rev 3829)
@@ -1,3 +1,10 @@
+2012-10-24 Romain Francois <romain at r-enthusiasts.com>
+
+ * include/Rcpp/traits/is_pointer.h: traits to identify if a type is a pointer
+ * include/Rcpp/traits/un_pointer.h: traits to remove a pointer
+ * include/Rcpp/module/Module_generated_get_return_type.h : handle pointer return types
+ * include/Rcpp/config.h: define RCPP_HAS_DEMANGLING for MAC OS <= 10.7 (up to Lion)
+
2012-10-23 Romain Francois <romain at r-enthusiasts.com>
* include/Rcpp/internal/wrap.h: new function module_wrap used internally by modules
Modified: pkg/Rcpp/inst/include/Rcpp/config.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/config.h 2012-10-24 06:51:53 UTC (rev 3828)
+++ pkg/Rcpp/inst/include/Rcpp/config.h 2012-10-24 12:44:22 UTC (rev 3829)
@@ -24,15 +24,18 @@
#ifdef __GNUC__
// from http://sourceforge.net/apps/mediawiki/predef/index.php?title=Operating_Systems#MacOS
- #ifndef __APPLE__
- #ifndef __MACH__
+ #ifdef __APPLE__
+ #include <Availability.h>
+ #ifndef __MAC_10_8
+ #define RCPP_HAS_DEMANGLING
+ #endif
+ #else
#define RCPP_HAS_DEMANGLING
- #endif
#endif
#endif
#define Rcpp_Version(v,p,s) (((v) * 65536) + ((p) * 256) + (s))
#define RCPP_VERSION Rcpp_Version(0,9,15)
-
+
#endif
Modified: pkg/Rcpp/inst/include/Rcpp/module/Module_generated_get_return_type.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/module/Module_generated_get_return_type.h 2012-10-24 06:51:53 UTC (rev 3828)
+++ pkg/Rcpp/inst/include/Rcpp/module/Module_generated_get_return_type.h 2012-10-24 12:44:22 UTC (rev 3829)
@@ -2,7 +2,7 @@
//
// Module_generated_get_return_type.h: Rcpp R/C++ interface class library --
//
-// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
+// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
@@ -25,14 +25,30 @@
struct void_type{} ;
template <typename OUT>
-inline std::string get_return_type(){
+inline std::string get_return_type_dispatch( Rcpp::traits::false_type ){
return demangle( typeid(OUT).name() ).data() ;
}
+template <typename OUT>
+inline std::string get_return_type_dispatch( Rcpp::traits::true_type ){
+ typedef typename Rcpp::traits::un_pointer<OUT>::type pointer ;
+ std::string res = demangle( typeid( pointer ).name() ).data() ;
+ res += "*" ;
+ return res ;
+}
+
+template <typename OUT>
+inline std::string get_return_type(){
+ return get_return_type_dispatch<OUT>( typename Rcpp::traits::is_pointer<OUT>::type() ) ;
+}
template <>
inline std::string get_return_type<void_type>(){
return "void" ;
}
template <>
+inline std::string get_return_type<SEXP>(){
+ return "SEXP" ;
+}
+template <>
inline std::string get_return_type<Rcpp::IntegerVector>(){
return "Rcpp::IntegerVector" ;
}
Added: pkg/Rcpp/inst/include/Rcpp/traits/is_pointer.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/is_pointer.h (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/traits/is_pointer.h 2012-10-24 12:44:22 UTC (rev 3829)
@@ -0,0 +1,35 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
+//
+// is_pointer.h: Rcpp R/C++ interface class library -- identifies if a type is a pointer
+//
+// Copyright (C) 2012 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__is_pointer__h
+#define Rcpp__traits__is_pointer__h
+
+namespace Rcpp{
+namespace traits{
+
+ template <typename T> struct is_pointer : public false_type{};
+ template <typename T> struct is_pointer<T*> : public true_type{};
+
+}
+}
+
+#endif
Modified: pkg/Rcpp/inst/include/Rcpp/traits/module_wrap_traits.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/module_wrap_traits.h 2012-10-24 06:51:53 UTC (rev 3828)
+++ pkg/Rcpp/inst/include/Rcpp/traits/module_wrap_traits.h 2012-10-24 12:44:22 UTC (rev 3829)
@@ -34,9 +34,6 @@
template <> struct module_wrap_traits<void> { typedef void_wrap_tag category; } ;
template <typename T> struct module_wrap_traits<T*> { typedef pointer_wrap_tag category; } ;
-template <typename T> struct un_pointer { typedef T type ;} ; // not used
-template <typename T> struct un_pointer<T*> { typedef T type ;} ;
-
} // namespace traits
} // namespace Rcpp
#endif
Added: pkg/Rcpp/inst/include/Rcpp/traits/un_pointer.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/traits/un_pointer.h (rev 0)
+++ pkg/Rcpp/inst/include/Rcpp/traits/un_pointer.h 2012-10-24 12:44:22 UTC (rev 3829)
@@ -0,0 +1,34 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
+//
+// un_pointer.h: Rcpp R/C++ interface class library --
+//
+// Copyright (C) 2012 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__un_pointer__h
+#define Rcpp__traits__un_pointer__h
+
+namespace Rcpp{
+namespace traits{
+
+template <typename T> struct un_pointer { typedef T type ;} ;
+template <typename T> struct un_pointer<T*> { typedef T type ;} ;
+
+} // namespace traits
+} // namespace Rcpp
+#endif
Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h 2012-10-24 06:51:53 UTC (rev 3828)
+++ pkg/Rcpp/inst/include/RcppCommon.h 2012-10-24 12:44:22 UTC (rev 3829)
@@ -297,6 +297,8 @@
#include <Rcpp/traits/r_sexptype_traits.h>
#include <Rcpp/traits/storage_type.h>
#include <Rcpp/traits/r_type_traits.h>
+#include <Rcpp/traits/un_pointer.h>
+#include <Rcpp/traits/is_pointer.h>
#include <Rcpp/traits/wrap_type_traits.h>
#include <Rcpp/traits/module_wrap_traits.h>
#include <Rcpp/traits/is_na.h>
More information about the Rcpp-commits
mailing list