Skip to content

Commit 01265c4

Browse files
committedApr 27, 2015
Merge pull request #293 from RcppCore/bugfix/revert-modules-begin-end-changes
Revert changes to modules related to BEGIN/END macros
2 parents ff3b8ef + ae5fe8f commit 01265c4

File tree

5 files changed

+566
-159
lines changed

5 files changed

+566
-159
lines changed
 

‎inst/include/Rcpp/InternalFunctionWithStdFunction.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ namespace Rcpp {
3838
virtual ~CppFunctionBaseFromStdFunction() {}
3939

4040
SEXP operator()(SEXP* args) {
41+
BEGIN_RCPP
4142
auto result = call<RESULT_TYPE, Args...>(fun, args);
4243
return Rcpp::module_wrap<RESULT_TYPE>(result);
44+
END_RCPP
4345
}
4446

4547
private:
@@ -53,8 +55,9 @@ namespace Rcpp {
5355
virtual ~CppFunctionBaseFromStdFunction() {}
5456

5557
SEXP operator()(SEXP* args) {
58+
BEGIN_RCPP
5659
call<void, Args...>(fun, args);
57-
return R_NilValue;
60+
END_RCPP
5861
}
5962

6063
private:

‎inst/include/Rcpp/api/meat/module/Module.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Module.h: Rcpp R/C++ interface class library -- Rcpp modules
22
//
3-
// Copyright (C) 2013 - 2015 Romain Francois
3+
// Copyright (C) 2013 Romain Francois
44
//
55
// This file is part of Rcpp.
66
//
@@ -37,10 +37,12 @@ namespace Rcpp {
3737
}
3838

3939
inline CppClass Module::get_class( const std::string& cl ){
40+
BEGIN_RCPP
4041
CLASS_MAP::iterator it = classes.find(cl) ;
4142
if( it == classes.end() ) throw std::range_error( "no such class" ) ;
4243
std::string buffer ;
4344
return CppClass( this, it->second, buffer ) ;
45+
END_RCPP
4446
}
4547

4648
}

‎inst/include/Rcpp/module/Module_generated_CppFunction.h

Lines changed: 529 additions & 133 deletions
Large diffs are not rendered by default.

‎inst/include/Rcpp/module/class.h

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@
121121
}
122122

123123
SEXP newInstance( SEXP* args, int nargs ){
124-
signed_constructor_class* p ;
124+
BEGIN_RCPP
125+
signed_constructor_class* p ;
125126
int n = constructors.size() ;
126127
for( int i=0; i<n; i++ ){
127128
p = constructors[i];
@@ -131,7 +132,7 @@
131132
return XP( ptr, true ) ;
132133
}
133134
}
134-
135+
135136
signed_factory_class* pfact ;
136137
n = factories.size() ;
137138
for( int i=0; i<n; i++){
@@ -142,9 +143,10 @@
142143
return XP( ptr, true ) ;
143144
}
144145
}
145-
146+
146147
throw std::range_error( "no valid constructor available for the argument list" ) ;
147-
}
148+
END_RCPP
149+
}
148150

149151
bool has_default_constructor(){
150152
int n = constructors.size() ;
@@ -163,7 +165,9 @@
163165
}
164166

165167
SEXP invoke( SEXP method_xp, SEXP object, SEXP *args, int nargs ){
166-
vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( EXTPTR_PTR( method_xp ) ) ;
168+
BEGIN_RCPP
169+
170+
vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( EXTPTR_PTR( method_xp ) ) ;
167171
typename vec_signed_method::iterator it = mets->begin() ;
168172
int n = mets->size() ;
169173
method_class* m = 0 ;
@@ -184,10 +188,13 @@
184188
} else {
185189
return Rcpp::List::create( false, m->operator()( XP(object), args ) ) ;
186190
}
187-
}
191+
END_RCPP
192+
}
188193

189194
SEXP invoke_void( SEXP method_xp, SEXP object, SEXP *args, int nargs ){
190-
vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( EXTPTR_PTR( method_xp ) ) ;
195+
BEGIN_RCPP
196+
197+
vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( EXTPTR_PTR( method_xp ) ) ;
191198
typename vec_signed_method::iterator it = mets->begin() ;
192199
int n = mets->size() ;
193200
method_class* m = 0 ;
@@ -203,11 +210,13 @@
203210
throw std::range_error( "could not find valid method" ) ;
204211
}
205212
m->operator()( XP(object), args );
206-
return R_NilValue ;
207-
}
213+
END_RCPP
214+
}
208215

209216
SEXP invoke_notvoid( SEXP method_xp, SEXP object, SEXP *args, int nargs ){
210-
vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( EXTPTR_PTR( method_xp ) ) ;
217+
BEGIN_RCPP
218+
219+
vec_signed_method* mets = reinterpret_cast< vec_signed_method* >( EXTPTR_PTR( method_xp ) ) ;
211220
typename vec_signed_method::iterator it = mets->begin() ;
212221
int n = mets->size() ;
213222
method_class* m = 0 ;
@@ -223,7 +232,8 @@
223232
throw std::range_error( "could not find valid method" ) ;
224233
}
225234
return m->operator()( XP(object), args ) ;
226-
}
235+
END_RCPP
236+
}
227237

228238

229239
self& AddMethod( const char* name_, method_class* m, ValidMethod valid = &yes, const char* docstring = 0){
@@ -382,14 +392,18 @@
382392
}
383393

384394
SEXP getProperty( SEXP field_xp , SEXP object) {
385-
prop_class* prop = reinterpret_cast< prop_class* >( EXTPTR_PTR( field_xp ) ) ;
395+
BEGIN_RCPP
396+
prop_class* prop = reinterpret_cast< prop_class* >( EXTPTR_PTR( field_xp ) ) ;
386397
return prop->get( XP(object) );
387-
}
398+
END_RCPP
399+
}
388400

389401
void setProperty( SEXP field_xp, SEXP object, SEXP value) {
390-
prop_class* prop = reinterpret_cast< prop_class* >( EXTPTR_PTR( field_xp ) ) ;
402+
BEGIN_RCPP
403+
prop_class* prop = reinterpret_cast< prop_class* >( EXTPTR_PTR( field_xp ) ) ;
391404
return prop->set( XP(object), value );
392-
}
405+
VOID_END_RCPP
406+
}
393407

394408

395409
Rcpp::List fields( const XP_Class& class_xp ){

‎src/Module.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,12 @@ END_RCPP
135135
}
136136

137137
SEXP class__newInstance(SEXP args) {
138-
BEGIN_RCPP
139138
SEXP p = CDR(args);
140139

141140
XP_Module module(CAR(p)); p = CDR(p);
142141
XP_Class clazz(CAR(p)); p = CDR(p);
143142
UNPACK_EXTERNAL_ARGS(cargs,p)
144143
return clazz->newInstance(cargs, nargs);
145-
END_RCPP
146144
}
147145

148146
// relies on being set in .onLoad()
@@ -166,7 +164,6 @@ SEXP class__dummyInstance(SEXP args) {
166164
}
167165

168166
SEXP CppMethod__invoke(SEXP args) {
169-
BEGIN_RCPP
170167
SEXP p = CDR(args);
171168

172169
// the external pointer to the class
@@ -181,13 +178,11 @@ BEGIN_RCPP
181178

182179
// additional arguments, processed the same way as .Call does
183180
UNPACK_EXTERNAL_ARGS(cargs,p)
184-
181+
185182
return clazz->invoke(met, obj, cargs, nargs);
186-
END_RCPP
187183
}
188184

189185
SEXP CppMethod__invoke_void(SEXP args) {
190-
BEGIN_RCPP
191186
SEXP p = CDR(args);
192187

193188
// the external pointer to the class
@@ -204,11 +199,9 @@ BEGIN_RCPP
204199
UNPACK_EXTERNAL_ARGS(cargs,p)
205200
clazz->invoke_void(met, obj, cargs, nargs);
206201
return R_NilValue;
207-
END_RCPP
208202
}
209203

210204
SEXP CppMethod__invoke_notvoid(SEXP args) {
211-
BEGIN_RCPP
212205
SEXP p = CDR(args);
213206

214207
// the external pointer to the class
@@ -225,7 +218,6 @@ BEGIN_RCPP
225218
UNPACK_EXTERNAL_ARGS(cargs,p)
226219

227220
return clazz->invoke_notvoid(met, obj, cargs, nargs);
228-
END_RCPP
229221
}
230222

231223
namespace Rcpp{

0 commit comments

Comments
 (0)
Please sign in to comment.