1
+ # !/usr/bin/Rscript
2
+ #
3
+ # Generator for inst/include/Rcpp/module/Module_generated_method.h
4
+ #
5
+ # Copyright (C) 2010 - 2014 Dirk Eddelbuettel and Romain Francois
1
6
2
7
3
- fun <- function ( i ) {
8
+ fun <- function (i ) {
4
9
5
- index <- (1 : i )- 1
6
- collapse <- function (x ) paste( x , collapse = " , " )
10
+ index <- (1 : i )- 1
11
+ collapse <- function (x ) paste(x , collapse = " , " )
7
12
8
- typenames <- collapse( sprintf( " typename U%d" , index ) )
9
- u <- collapse( sprintf( " U%d u%d" , index , index ) )
10
- as <- collapse( sprintf( " Rcpp::as< typename Rcpp::traits::remove_const_and_reference< U%d >::type >( args[%d] )" , index , index ) )
11
- U <- collapse( sprintf( " U%d" , index ) )
13
+ typenames <- collapse(sprintf(" typename U%d" , index ))
14
+ u <- collapse(sprintf(" U%d u%d" , index , index ))
15
+ as <- collapse(sprintf(" Rcpp::as< typename Rcpp::traits::remove_const_and_reference<U%d>::type>(args[%d])" ,
16
+ index , index ))
17
+ U <- collapse(sprintf(" U%d" , index ))
12
18
13
- txt <- sprintf( '
19
+ txt <- sprintf('
14
20
15
- template <typename RESULT_TYPE, %s>
16
- self& method( const char* name_, RESULT_TYPE (Class::*fun)(%s), const char* docstring = 0, ValidMethod valid = &yes_arity<%d> ){
17
- AddMethod( name_, new CppMethod%d<Class,RESULT_TYPE,%s>( fun ), valid, docstring) ;
18
- return *this ;
19
- }
20
-
21
- template <typename RESULT_TYPE, %s>
22
- self& method( const char* name_, RESULT_TYPE (Class::*fun)(%s) const, const char* docstring = 0, ValidMethod valid = &yes_arity<%d> ){
23
- AddMethod( name_, new const_CppMethod%d<Class,RESULT_TYPE,%s>( fun ), valid, docstring ) ;
24
- return *this ;
25
- }
26
-
27
- template <typename RESULT_TYPE, %s>
28
- self& nonconst_method( const char* name_, RESULT_TYPE (Class::*fun)(%s), const char* docstring = 0, ValidMethod valid = &yes_arity<%d> ){
29
- AddMethod( name_, new CppMethod%d<Class,RESULT_TYPE,%s>( fun ), valid, docstring ) ;
30
- return *this ;
31
- }
32
-
33
- template <typename RESULT_TYPE, %s>
34
- self& const_method( const char* name_, RESULT_TYPE (Class::*fun)(%s) const, const char* docstring = 0, ValidMethod valid = &yes_arity<%d>){
35
- AddMethod( name_, new const_CppMethod%d<Class,RESULT_TYPE,%s>( fun ), valid, docstring ) ;
36
- return *this ;
37
- }
38
-
39
- ' ,
40
- typenames , # typename U0, ...
41
- u , # U0 u0, ...
42
- i ,
43
- i ,
44
- U , # U0, ...
45
-
46
- typenames , # typename U0, ...
47
- u , # U0 u0, ...
48
- i ,
49
- i ,
50
- U , # U0, ...
51
-
52
- typenames , # typename U0, ...
53
- u , # U0 u0, ...
54
- i ,
55
- i ,
56
- U , # U0, ...
57
-
58
- typenames , # typename U0, ...
59
- u , # U0 u0, ...
60
- i ,
61
- i ,
62
- U # U0, ...
21
+ template <typename RESULT_TYPE, %s>
22
+ self& method(const char* name_, RESULT_TYPE (Class::*fun)(%s),
23
+ const char* docstring = 0, ValidMethod valid = &yes_arity<%d>) {
24
+ AddMethod( name_, new CppMethod%d<Class,RESULT_TYPE,%s>(fun), valid, docstring);
25
+ return *this;
26
+ }
27
+
28
+ template <typename RESULT_TYPE, %s>
29
+ self& method(const char* name_, RESULT_TYPE (Class::*fun)(%s) const,
30
+ const char* docstring = 0, ValidMethod valid = &yes_arity<%d>) {
31
+ AddMethod(name_, new const_CppMethod%d<Class,RESULT_TYPE,%s>(fun), valid, docstring);
32
+ return *this ;
33
+ }
63
34
35
+ template <typename RESULT_TYPE, %s>
36
+ self& nonconst_method(const char* name_, RESULT_TYPE (Class::*fun)(%s),
37
+ const char* docstring = 0, ValidMethod valid = &yes_arity<%d>) {
38
+ AddMethod(name_, new CppMethod%d<Class,RESULT_TYPE,%s>( fun ), valid, docstring);
39
+ return *this;
40
+ }
41
+
42
+ template <typename RESULT_TYPE, %s>
43
+ self& const_method(const char* name_, RESULT_TYPE (Class::*fun)(%s) const,
44
+ const char* docstring = 0, ValidMethod valid = &yes_arity<%d>) {
45
+ AddMethod(name_, new const_CppMethod%d<Class,RESULT_TYPE,%s>( fun ), valid, docstring);
46
+ return *this;
47
+ }' ,
48
+ typenames , # typename U0, ...
49
+ u , # U0 u0, ...
50
+ i ,
51
+ i ,
52
+ U , # U0, ...
53
+
54
+ typenames , # typename U0, ...
55
+ u , # U0 u0, ...
56
+ i ,
57
+ i ,
58
+ U , # U0, ...
59
+
60
+ typenames , # typename U0, ...
61
+ u , # U0 u0, ...
62
+ i ,
63
+ i ,
64
+ U , # U0, ...
65
+
66
+ typenames , # typename U0, ...
67
+ u , # U0 u0, ...
68
+ i ,
69
+ i ,
70
+ U # U0, ...
64
71
)
65
72
66
73
}
67
74
68
75
file <- sprintf(
69
- ' // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
76
+ ' // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
70
77
//
71
- // Module_generated_method.h: Rcpp R/C++ interface class library -- Rcpp modules
78
+ // Module_generated_method.h: -- generated helper code for Modules
79
+ // see rcpp-scripts repo for generator script
72
80
//
73
81
// Copyright (C) 2010 - 2014 Dirk Eddelbuettel and Romain Francois
74
82
//
@@ -90,38 +98,42 @@ file <- sprintf(
90
98
#ifndef Rcpp_Module_generated_method_h
91
99
#define Rcpp_Module_generated_method_h
92
100
93
- template <typename RESULT_TYPE>
94
- self& method( const char* name_, RESULT_TYPE (Class::*fun)(void), const char* docstring = 0, ValidMethod valid = &yes ){
95
- AddMethod( name_, new CppMethod0<Class,RESULT_TYPE>( fun ), valid, docstring) ;
96
- return *this ;
97
- }
98
-
99
- template <typename RESULT_TYPE>
100
- self& method( const char* name_, RESULT_TYPE (Class::*fun)(void) const, const char* docstring = 0, ValidMethod valid = &yes ){
101
- AddMethod( name_, new const_CppMethod0<Class,RESULT_TYPE>( fun ), valid, docstring ) ;
102
- return *this ;
103
- }
101
+ template <typename RESULT_TYPE>
102
+ self& method(const char* name_, RESULT_TYPE (Class::*fun)(void),
103
+ const char* docstring = 0, ValidMethod valid = &yes) {
104
+ AddMethod(name_, new CppMethod0<Class,RESULT_TYPE>(fun), valid, docstring);
105
+ return *this;
106
+ }
107
+
108
+ template <typename RESULT_TYPE>
109
+ self& method(const char* name_, RESULT_TYPE (Class::*fun)(void) const,
110
+ const char* docstring = 0, ValidMethod valid = &yes) {
111
+ AddMethod( name_, new const_CppMethod0<Class,RESULT_TYPE>(fun), valid, docstring);
112
+ return *this;
113
+ }
114
+
115
+ template <typename RESULT_TYPE>
116
+ self& nonconst_method(const char* name_, RESULT_TYPE (Class::*fun)(void),
117
+ const char* docstring = 0, ValidMethod valid = &yes ){
118
+ AddMethod( name_, new CppMethod0<Class,RESULT_TYPE>( fun ) , valid, docstring ) ;
119
+ return *this ;
120
+ }
121
+
122
+ template <typename RESULT_TYPE>
123
+ self& const_method(const char* name_, RESULT_TYPE (Class::*fun)(void) const,
124
+ const char* docstring = 0, ValidMethod valid = &yes ){
125
+ AddMethod( name_, new const_CppMethod0<Class,RESULT_TYPE>( fun ), valid, docstring ) ;
126
+ return *this ;
127
+ }
104
128
105
-
106
- template <typename RESULT_TYPE>
107
- self& nonconst_method( const char* name_, RESULT_TYPE (Class::*fun)(void), const char* docstring = 0, ValidMethod valid = &yes ){
108
- AddMethod( name_, new CppMethod0<Class,RESULT_TYPE>( fun ) , valid, docstring ) ;
109
- return *this ;
110
- }
111
- template <typename RESULT_TYPE>
112
- self& const_method( const char* name_, RESULT_TYPE (Class::*fun)(void) const, const char* docstring = 0, ValidMethod valid = &yes ){
113
- AddMethod( name_, new const_CppMethod0<Class,RESULT_TYPE>( fun ), valid, docstring ) ;
114
- return *this ;
115
- }
116
-
117
-
118
129
%s
119
130
120
131
#endif
121
132
' , paste( sapply( 1 : 65 , fun ), collapse = " \n " )
122
133
)
123
134
124
- writeLines( file , " Rcpp/inst/include/Rcpp/module/Module_generated_method.h" )
135
+ stopifnot(file.exists(" inst/include/Rcpp/module/" ))
136
+ writeLines( file , " inst/include/Rcpp/module/Module_generated_method.h" )
125
137
126
138
127
139
0 commit comments