1
- // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
1
+ // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2
2
//
3
3
// Module.cpp: Rcpp R/C++ interface class library -- Rcpp modules
4
4
//
5
- // Copyright (C) 2010 - 2015 Dirk Eddelbuettel and Romain Francois
5
+ // Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
6
6
//
7
7
// This file is part of Rcpp.
8
8
//
@@ -34,113 +34,113 @@ RCPP_FUN_1(bool, Class__has_default_constructor, XP_Class cl) {
34
34
RCPP_FUN_2 (SEXP, Module__get_function, XP_Module module , std::string fun) {
35
35
return module ->get_function (fun);
36
36
}
37
- RCPP_FUN_2 (bool , Class__has_method, XP_Class cl, std::string m) {
38
- return cl->has_method (m);
37
+ RCPP_FUN_2 (bool , Class__has_method, XP_Class cl, std::string m) { // #nocov start
38
+ return cl->has_method (m);
39
39
}
40
40
RCPP_FUN_2 (bool , Class__has_property, XP_Class cl, std::string m) {
41
- return cl->has_property (m);
41
+ return cl->has_property (m);
42
42
}
43
43
RCPP_FUN_1 (std::string, Class__name, XP_Class cl) {
44
- return cl->name ;
44
+ return cl->name ;
45
45
}
46
46
RCPP_FUN_2 (bool , Module__has_function, XP_Module module , std::string met) {
47
- return module ->has_function (met);
47
+ return module ->has_function (met);
48
48
}
49
49
RCPP_FUN_2 (bool , Module__has_class, XP_Module module , std::string cl) {
50
- return module ->has_class (cl);
51
- }
50
+ return module ->has_class (cl);
51
+ } // #nocov end
52
52
RCPP_FUN_2 (Rcpp::CppClass, Module__get_class, XP_Module module , std::string cl) {
53
- return module ->get_class (cl);
53
+ return module ->get_class (cl);
54
54
}
55
- RCPP_FUN_1 (bool , CppObject__needs_init, SEXP xp) {
56
- return EXTPTR_PTR (xp) == 0 ;
55
+ RCPP_FUN_1 (bool , CppObject__needs_init, SEXP xp) { // #nocov start
56
+ return EXTPTR_PTR (xp) == 0 ;
57
57
}
58
58
RCPP_FUN_1 (Rcpp::CharacterVector, CppClass__methods, XP_Class cl) {
59
- return cl->method_names ();
59
+ return cl->method_names ();
60
60
}
61
61
RCPP_FUN_1 (Rcpp::CharacterVector, CppClass__properties, XP_Class cl) {
62
- return cl->property_names ();
62
+ return cl->property_names ();
63
63
}
64
64
RCPP_FUN_1 (Rcpp::List, CppClass__property_classes, XP_Class cl) {
65
- return cl->property_classes ();
65
+ return cl->property_classes ();
66
66
}
67
67
68
68
RCPP_FUN_1 (Rcpp::IntegerVector, CppClass__methods_arity, XP_Class cl) {
69
- return cl->methods_arity ();
69
+ return cl->methods_arity ();
70
70
}
71
71
RCPP_FUN_1 (Rcpp::LogicalVector, CppClass__methods_voidness, XP_Class cl) {
72
- return cl->methods_voidness ();
72
+ return cl->methods_voidness ();
73
73
}
74
74
75
75
76
76
RCPP_FUN_2 (bool , CppClass__property_is_readonly, XP_Class cl, std::string p) {
77
- return cl->property_is_readonly (p);
77
+ return cl->property_is_readonly (p);
78
78
}
79
79
RCPP_FUN_2 (std::string, CppClass__property_class, XP_Class cl, std::string p) {
80
- return cl->property_class (p);
80
+ return cl->property_class (p);
81
81
}
82
82
83
83
RCPP_FUN_1 (Rcpp::IntegerVector, Module__functions_arity, XP_Module module ) {
84
- return module -> functions_arity ();
85
- }
84
+ return module -> functions_arity ();
85
+ } // #nocov end
86
86
RCPP_FUN_1 (Rcpp::CharacterVector, Module__functions_names, XP_Module module ) {
87
- return module -> functions_names ();
88
- }
89
- RCPP_FUN_1 (std::string, Module__name, XP_Module module ) {
90
- return module ->name ;
87
+ return module -> functions_names ();
91
88
}
89
+ RCPP_FUN_1 (std::string, Module__name, XP_Module module ) { // #nocov start
90
+ return module ->name ;
91
+ } // #nocov end
92
92
RCPP_FUN_1 (Rcpp::List, Module__classes_info, XP_Module module ) {
93
- return module ->classes_info ();
93
+ return module ->classes_info ();
94
94
}
95
- RCPP_FUN_1 (Rcpp::CharacterVector, Module__complete, XP_Module module ) {
96
- return module ->complete ();
95
+ RCPP_FUN_1 (Rcpp::CharacterVector, Module__complete, XP_Module module ) { // #nocov start
96
+ return module ->complete ();
97
97
}
98
98
RCPP_FUN_1 (Rcpp::CharacterVector, CppClass__complete, XP_Class cl) {
99
- return cl->complete ();
99
+ return cl->complete ();
100
100
}
101
101
102
102
// these operate directly on the external pointers, rather than
103
- // looking up the property in the map
103
+ // looking up the property in the map // #nocov end
104
104
RCPP_FUN_3 (SEXP, CppField__get, XP_Class cl, SEXP field_xp, SEXP obj) {
105
- return cl->getProperty (field_xp, obj);
105
+ return cl->getProperty (field_xp, obj);
106
106
}
107
107
RCPP_FUN_4 (SEXP, CppField__set, XP_Class cl, SEXP field_xp, SEXP obj, SEXP value) {
108
- cl->setProperty (field_xp, obj, value);
109
- return R_NilValue;
108
+ cl->setProperty (field_xp, obj, value);
109
+ return R_NilValue;
110
110
}
111
111
RCPP_FUN_2 (SEXP, CppObject__finalize, XP_Class cl, SEXP obj) {
112
- cl->run_finalizer (obj);
113
- return R_NilValue;
112
+ cl->run_finalizer (obj);
113
+ return R_NilValue;
114
114
}
115
115
116
116
// .External functions
117
117
SEXP InternalFunction_invoke (SEXP args) {
118
118
BEGIN_RCPP
119
- SEXP p = CDR (args);
120
- XP_Function fun (CAR (p)); p = CDR (p);
121
- UNPACK_EXTERNAL_ARGS (cargs,p)
122
- return fun->operator ()(cargs);
119
+ SEXP p = CDR (args);
120
+ XP_Function fun (CAR (p)); p = CDR (p);
121
+ UNPACK_EXTERNAL_ARGS (cargs,p)
122
+ return fun->operator ()(cargs);
123
123
END_RCPP
124
124
}
125
125
126
- SEXP Module__invoke (SEXP args) {
126
+ SEXP Module__invoke (SEXP args) { // #nocov start
127
127
BEGIN_RCPP
128
- SEXP p = CDR (args);
129
- XP_Module module (CAR (p)); p = CDR (p);
130
- std::string fun = Rcpp::as<std::string>(CAR (p)); p = CDR (p);
128
+ SEXP p = CDR (args);
129
+ XP_Module module (CAR (p)); p = CDR (p);
130
+ std::string fun = Rcpp::as<std::string>(CAR (p)); p = CDR (p);
131
131
132
- UNPACK_EXTERNAL_ARGS (cargs,p)
133
- return module ->invoke (fun, cargs, nargs);
132
+ UNPACK_EXTERNAL_ARGS (cargs,p)
133
+ return module ->invoke (fun, cargs, nargs);
134
134
END_RCPP
135
- }
135
+ } // #nocov end
136
136
137
137
SEXP class__newInstance (SEXP args) {
138
- SEXP p = CDR (args);
138
+ SEXP p = CDR (args);
139
139
140
- XP_Module module (CAR (p)); p = CDR (p);
141
- XP_Class clazz (CAR (p)); p = CDR (p);
142
- UNPACK_EXTERNAL_ARGS (cargs,p)
143
- return clazz->newInstance (cargs, nargs);
140
+ XP_Module module (CAR (p)); p = CDR (p);
141
+ XP_Class clazz (CAR (p)); p = CDR (p);
142
+ UNPACK_EXTERNAL_ARGS (cargs,p)
143
+ return clazz->newInstance (cargs, nargs);
144
144
}
145
145
146
146
// relies on being set in .onLoad()
@@ -150,78 +150,78 @@ SEXP rcpp_dummy_pointer = R_NilValue;
150
150
151
151
152
152
SEXP class__dummyInstance(SEXP args) {
153
- SEXP p;
153
+ SEXP p;
154
154
155
- if (args == R_NilValue) {
156
- return rcpp_dummy_pointer;
155
+ if (args == R_NilValue) {
156
+ return rcpp_dummy_pointer; // #nocov
157
157
}
158
- p = CDR (args);
158
+ p = CDR (args);
159
159
160
- if (p != R_NilValue) {
161
- rcpp_dummy_pointer = CAR (p);
160
+ if (p != R_NilValue) {
161
+ rcpp_dummy_pointer = CAR (p);
162
162
}
163
- return rcpp_dummy_pointer;
163
+ return rcpp_dummy_pointer;
164
164
}
165
165
166
- SEXP CppMethod__invoke (SEXP args) {
167
- SEXP p = CDR (args);
166
+ SEXP CppMethod__invoke (SEXP args) { // #nocov start
167
+ SEXP p = CDR (args);
168
168
169
- // the external pointer to the class
170
- XP_Class clazz (CAR (p)); p = CDR (p);
169
+ // the external pointer to the class
170
+ XP_Class clazz (CAR (p)); p = CDR (p);
171
171
172
- // the external pointer to the method
173
- SEXP met = CAR (p); p = CDR (p);
172
+ // the external pointer to the method
173
+ SEXP met = CAR (p); p = CDR (p);
174
174
175
- // the external pointer to the object
176
- SEXP obj = CAR (p); p = CDR (p);
177
- CHECK_DUMMY_OBJ (obj);
175
+ // the external pointer to the object
176
+ SEXP obj = CAR (p); p = CDR (p);
177
+ CHECK_DUMMY_OBJ (obj);
178
178
179
- // additional arguments, processed the same way as .Call does
180
- UNPACK_EXTERNAL_ARGS (cargs,p)
179
+ // additional arguments, processed the same way as .Call does
180
+ UNPACK_EXTERNAL_ARGS (cargs,p)
181
181
182
- return clazz->invoke (met, obj, cargs, nargs);
183
- }
182
+ return clazz->invoke (met, obj, cargs, nargs);
183
+ } // #nocov end
184
184
185
185
SEXP CppMethod__invoke_void (SEXP args) {
186
- SEXP p = CDR (args);
186
+ SEXP p = CDR (args);
187
187
188
- // the external pointer to the class
189
- XP_Class clazz (CAR (p)); p = CDR (p);
188
+ // the external pointer to the class
189
+ XP_Class clazz (CAR (p)); p = CDR (p);
190
190
191
- // the external pointer to the method
192
- SEXP met = CAR (p); p = CDR (p);
191
+ // the external pointer to the method
192
+ SEXP met = CAR (p); p = CDR (p);
193
193
194
- // the external pointer to the object
195
- SEXP obj = CAR (p); p = CDR (p);
196
- CHECK_DUMMY_OBJ (obj);
194
+ // the external pointer to the object
195
+ SEXP obj = CAR (p); p = CDR (p);
196
+ CHECK_DUMMY_OBJ (obj);
197
197
198
- // additional arguments, processed the same way as .Call does
199
- UNPACK_EXTERNAL_ARGS (cargs,p)
200
- clazz->invoke_void (met, obj, cargs, nargs);
201
- return R_NilValue;
198
+ // additional arguments, processed the same way as .Call does
199
+ UNPACK_EXTERNAL_ARGS (cargs,p)
200
+ clazz->invoke_void (met, obj, cargs, nargs);
201
+ return R_NilValue;
202
202
}
203
203
204
204
SEXP CppMethod__invoke_notvoid (SEXP args) {
205
- SEXP p = CDR (args);
205
+ SEXP p = CDR (args);
206
206
207
- // the external pointer to the class
208
- XP_Class clazz (CAR (p)); p = CDR (p);
207
+ // the external pointer to the class
208
+ XP_Class clazz (CAR (p)); p = CDR (p);
209
209
210
- // the external pointer to the method
211
- SEXP met = CAR (p); p = CDR (p);
210
+ // the external pointer to the method
211
+ SEXP met = CAR (p); p = CDR (p);
212
212
213
- // the external pointer to the object
214
- SEXP obj = CAR (p); p = CDR (p);
215
- CHECK_DUMMY_OBJ (obj);
213
+ // the external pointer to the object
214
+ SEXP obj = CAR (p); p = CDR (p);
215
+ CHECK_DUMMY_OBJ (obj);
216
216
217
- // additional arguments, processed the same way as .Call does
218
- UNPACK_EXTERNAL_ARGS (cargs,p)
217
+ // additional arguments, processed the same way as .Call does
218
+ UNPACK_EXTERNAL_ARGS (cargs,p)
219
219
220
- return clazz->invoke_notvoid (met, obj, cargs, nargs);
220
+ return clazz->invoke_notvoid (met, obj, cargs, nargs);
221
221
}
222
222
223
223
namespace Rcpp {
224
- static Module* current_scope ;
224
+ static Module* current_scope ;
225
225
}
226
226
227
227
Rcpp::Module* getCurrentScope () {
0 commit comments