[Rcpp-commits] r2775 - in pkg/Rcpp/inst/include/Rcpp: . module

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Dec 12 10:08:36 CET 2010


Author: romain
Date: 2010-12-12 10:08:36 +0100 (Sun, 12 Dec 2010)
New Revision: 2775

Modified:
   pkg/Rcpp/inst/include/Rcpp/Module.h
   pkg/Rcpp/inst/include/Rcpp/module/Module_generated_Constructor.h
   pkg/Rcpp/inst/include/Rcpp/module/Module_generated_ctor_signature.h
Log:
also reuse strings in ctors

Modified: pkg/Rcpp/inst/include/Rcpp/Module.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Module.h	2010-12-12 08:53:48 UTC (rev 2774)
+++ pkg/Rcpp/inst/include/Rcpp/Module.h	2010-12-12 09:08:36 UTC (rev 2775)
@@ -224,7 +224,9 @@
         field( "pointer" )       = Rcpp::XPtr< SignedConstructor<Class> >( m, false ) ;
         field( "class_pointer" ) = class_xp ;
         field( "nargs" )         = m->nargs() ;
-        field( "signature" )     = m->signature(class_name) ;
+        std::string sign ;
+        m->signature( sign, class_name ) ;
+        field( "signature" )     = sign ;
         field( "docstring" )     = m->docstring ;
     }
 } ;

Modified: pkg/Rcpp/inst/include/Rcpp/module/Module_generated_Constructor.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/module/Module_generated_Constructor.h	2010-12-12 08:53:48 UTC (rev 2774)
+++ pkg/Rcpp/inst/include/Rcpp/module/Module_generated_Constructor.h	2010-12-12 09:08:36 UTC (rev 2775)
@@ -27,7 +27,7 @@
 public:
     virtual Class* get_new( SEXP* args, int nargs ) = 0 ;
     virtual int nargs() = 0 ;
-    virtual const SEXP signature(const std::string& class_name) = 0 ;
+    virtual void signature(std::string& s, const std::string& class_name) = 0 ;
 } ;
 
 template <typename Class>
@@ -37,8 +37,8 @@
 	return new Class() ;
     }
     virtual int nargs(){ return 0 ; }
-    virtual const SEXP signature(const std::string& class_name ){
-        return ctor_signature(class_name) ;
+    virtual void signature(std::string& s, const std::string& class_name ){
+        ctor_signature(s, class_name) ;
     }
 } ;
 template <typename Class, typename U0>
@@ -47,8 +47,8 @@
         return new Class( as<U0>(args[0]) ) ;
     }
     virtual int nargs(){ return 1 ; }
-    virtual const SEXP signature(const std::string& class_name ){
-        return ctor_signature<U0>(class_name) ;
+    virtual void signature(std::string& s, const std::string& class_name ){
+        ctor_signature<U0>(s, class_name) ;
     }
 } ;
 template <typename Class, typename U0, typename U1>
@@ -60,8 +60,8 @@
             ) ;
     }
     virtual int nargs(){ return 2 ; }
-    virtual const SEXP signature(const std::string& class_name ){
-        return ctor_signature<U0,U1>(class_name) ;
+    virtual void signature(std::string& s, const std::string& class_name ){
+        ctor_signature<U0,U1>(s, class_name) ;
     }
 } ;
 template <typename Class, typename U0, typename U1, typename U2>
@@ -74,8 +74,8 @@
             ) ;
     }
     virtual int nargs(){ return 3 ; }
-    virtual const SEXP signature(const std::string& class_name ){
-        return ctor_signature<U0,U1,U2>(class_name) ;
+    virtual void signature(std::string& s, const std::string& class_name ){
+        ctor_signature<U0,U1,U2>(s, class_name) ;
     }
 } ;
 template <typename Class, typename U0, typename U1, typename U2, typename U3>
@@ -89,8 +89,8 @@
             ) ;
     }
     virtual int nargs(){ return 4 ; }
-    virtual const SEXP signature(const std::string& class_name ){
-        return ctor_signature<U0,U1,U2,U3>(class_name) ;
+    virtual void signature(std::string& s, const std::string& class_name ){
+        ctor_signature<U0,U1,U2,U3>(s, class_name) ;
     }
 } ;
 template <typename Class, typename U0, typename U1, typename U2, typename U3, typename U4>
@@ -105,8 +105,8 @@
             ) ;
     }
     virtual int nargs(){ return 5 ; }
-    virtual const SEXP signature(const std::string& class_name ){
-        return ctor_signature<U0,U1,U2,U3,U4>(class_name) ;
+    virtual void signature(std::string& s, const std::string& class_name ){
+        ctor_signature<U0,U1,U2,U3,U4>(s, class_name) ;
     }
 } ;
 template <typename Class, typename U0, typename U1, typename U2, typename U3, typename U4, typename U5>
@@ -122,8 +122,8 @@
             ) ;
     }
     virtual int nargs(){ return 6 ; }
-    virtual const SEXP signature(const std::string& class_name ){
-        return ctor_signature<U0,U1,U2,U3,U4,U5>(class_name) ;
+    virtual void signature(std::string& s, const std::string& class_name ){
+        ctor_signature<U0,U1,U2,U3,U4,U5>(s, class_name) ;
     }
 } ;
 template <typename Class, typename U0, typename U1, typename U2, typename U3, typename U4, typename U5, typename U6>
@@ -136,12 +136,12 @@
             as<U3>(args[3]), 
             as<U4>(args[4]),
             as<U5>(args[5]),
-						as<U6>(args[6]) 
+            as<U6>(args[6]) 
             ) ;
     }
     virtual int nargs(){ return 7 ; }
-    virtual const SEXP signature(const std::string& class_name ){
-        return ctor_signature<U0,U1,U2,U3,U4,U5,U6>(class_name) ;
+    virtual void signature(std::string& s, const std::string& class_name ){
+        ctor_signature<U0,U1,U2,U3,U4,U5,U6>(s, class_name) ;
     }
 } ;
 

Modified: pkg/Rcpp/inst/include/Rcpp/module/Module_generated_ctor_signature.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/module/Module_generated_ctor_signature.h	2010-12-12 08:53:48 UTC (rev 2774)
+++ pkg/Rcpp/inst/include/Rcpp/module/Module_generated_ctor_signature.h	2010-12-12 09:08:36 UTC (rev 2775)
@@ -22,57 +22,52 @@
 #ifndef Rcpp_Module_generated_ctor_signature_h
 #define Rcpp_Module_generated_ctor_signature_h
 
-inline const SEXP ctor_signature( const std::string& classname ){
-    std::string s( classname ) ;
+inline void ctor_signature( std::string& s, const std::string& classname ){
+    s.clear() ;
     s+= "()" ; 
-    return Rf_mkString(s.c_str()) ;
 }
 
 template <typename U0>
-inline const SEXP ctor_signature( const std::string& classname ){
-    std::string s( classname ) ;
+inline void ctor_signature( std::string& s, const std::string& classname ){
+    s.clear() ;
     s += "(" ; 
     s += get_return_type<U0>() ;
     s += ")" ;
-    return Rf_mkString(s.c_str()) ;
 }
 
 template <typename U0, typename U1>
-inline const SEXP ctor_signature( const std::string& classname ){
-    std::string s( classname ) ;
+inline void ctor_signature( std::string& s, const std::string& classname ){
+    s.clear() ;
     s += "(" ; 
     s += get_return_type<U0>() ;
     s += ", " ; s+= get_return_type<U1>() ;
     s += ")" ;
-    return Rf_mkString(s.c_str()) ;
 }
 
 template <typename U0, typename U1, typename U2>
-inline const SEXP ctor_signature( const std::string& classname ){
-    std::string s( classname ) ;
+inline void ctor_signature( std::string& s, const std::string& classname ){
+    s.clear() ;
     s += "(" ; 
     s += get_return_type<U0>() ;
     s += ", " ; s+= get_return_type<U1>() ;
     s += ", " ; s+= get_return_type<U2>() ;
     s += ")" ;
-    return Rf_mkString(s.c_str()) ;
 }
 
 template <typename U0, typename U1, typename U2, typename U3>
-inline const SEXP ctor_signature( const std::string& classname ){
-    std::string s( classname ) ;
+inline void ctor_signature( std::string& s, const std::string& classname ){
+    s.clear() ;
     s += "(" ; 
     s += get_return_type<U0>() ;
     s += ", " ; s+= get_return_type<U1>() ;
     s += ", " ; s+= get_return_type<U2>() ;
     s += ", " ; s+= get_return_type<U3>() ;
     s += ")" ;
-    return Rf_mkString(s.c_str()) ;
 }
 
 template <typename U0, typename U1, typename U2, typename U3, typename U4>
-inline const SEXP ctor_signature( const std::string& classname ){
-    std::string s( classname ) ;
+inline void ctor_signature( std::string& s, const std::string& classname ){
+    s.clear() ;
     s += "(" ; 
     s += get_return_type<U0>() ;
     s += ", " ; s+= get_return_type<U1>() ;
@@ -80,12 +75,11 @@
     s += ", " ; s+= get_return_type<U3>() ;
     s += ", " ; s+= get_return_type<U4>() ;
     s += ")" ;
-    return Rf_mkString(s.c_str()) ;
 }
 
 template <typename U0, typename U1, typename U2, typename U3, typename U4, typename U5>
-inline const SEXP ctor_signature( const std::string& classname ){
-    std::string s( classname ) ;
+inline void ctor_signature( std::string& s, const std::string& classname ){
+    s.clear() ;
     s += "(" ; 
     s += get_return_type<U0>() ;
     s += ", " ; s+= get_return_type<U1>() ;
@@ -94,12 +88,11 @@
     s += ", " ; s+= get_return_type<U4>() ;
     s += ", " ; s+= get_return_type<U5>() ;
     s += ")" ;
-    return Rf_mkString(s.c_str()) ;
 }
 
 template <typename U0, typename U1, typename U2, typename U3, typename U4, typename U5, typename U6>
-inline const SEXP ctor_signature( const std::string& classname ){
-    std::string s( classname ) ;
+inline void ctor_signature( std::string& s, const std::string& classname ){
+    s.clear() ;
     s += "(" ; 
     s += get_return_type<U0>() ;
     s += ", " ; s+= get_return_type<U1>() ;
@@ -109,7 +102,6 @@
     s += ", " ; s+= get_return_type<U5>() ;
     s += ", " ; s+= get_return_type<U6>() ;
     s += ")" ;
-    return Rf_mkString(s.c_str()) ;
 }
 
 



More information about the Rcpp-commits mailing list