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; -*-
22//
33// Module.cpp: Rcpp R/C++ interface class library -- Rcpp modules
44//
5- // Copyright (C) 2010 - 2015 Dirk Eddelbuettel and Romain Francois
5+ // Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
66//
77// This file is part of Rcpp.
88//
@@ -34,113 +34,113 @@ RCPP_FUN_1(bool, Class__has_default_constructor, XP_Class cl) {
3434RCPP_FUN_2 (SEXP, Module__get_function, XP_Module module , std::string fun) {
3535 return module ->get_function (fun);
3636}
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);
3939}
4040RCPP_FUN_2 (bool , Class__has_property, XP_Class cl, std::string m) {
41- return cl->has_property (m);
41+ return cl->has_property (m);
4242}
4343RCPP_FUN_1 (std::string, Class__name, XP_Class cl) {
44- return cl->name ;
44+ return cl->name ;
4545}
4646RCPP_FUN_2 (bool , Module__has_function, XP_Module module , std::string met) {
47- return module ->has_function (met);
47+ return module ->has_function (met);
4848}
4949RCPP_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
5252RCPP_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);
5454}
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 ;
5757}
5858RCPP_FUN_1 (Rcpp::CharacterVector, CppClass__methods, XP_Class cl) {
59- return cl->method_names ();
59+ return cl->method_names ();
6060}
6161RCPP_FUN_1 (Rcpp::CharacterVector, CppClass__properties, XP_Class cl) {
62- return cl->property_names ();
62+ return cl->property_names ();
6363}
6464RCPP_FUN_1 (Rcpp::List, CppClass__property_classes, XP_Class cl) {
65- return cl->property_classes ();
65+ return cl->property_classes ();
6666}
6767
6868RCPP_FUN_1 (Rcpp::IntegerVector, CppClass__methods_arity, XP_Class cl) {
69- return cl->methods_arity ();
69+ return cl->methods_arity ();
7070}
7171RCPP_FUN_1 (Rcpp::LogicalVector, CppClass__methods_voidness, XP_Class cl) {
72- return cl->methods_voidness ();
72+ return cl->methods_voidness ();
7373}
7474
7575
7676RCPP_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);
7878}
7979RCPP_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);
8181}
8282
8383RCPP_FUN_1 (Rcpp::IntegerVector, Module__functions_arity, XP_Module module ) {
84- return module -> functions_arity ();
85- }
84+ return module -> functions_arity ();
85+ } // #nocov end
8686RCPP_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 ();
9188}
89+ RCPP_FUN_1 (std::string, Module__name, XP_Module module ) { // #nocov start
90+ return module ->name ;
91+ } // #nocov end
9292RCPP_FUN_1 (Rcpp::List, Module__classes_info, XP_Module module ) {
93- return module ->classes_info ();
93+ return module ->classes_info ();
9494}
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 ();
9797}
9898RCPP_FUN_1 (Rcpp::CharacterVector, CppClass__complete, XP_Class cl) {
99- return cl->complete ();
99+ return cl->complete ();
100100}
101101
102102// 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
104104RCPP_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);
106106}
107107RCPP_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;
110110}
111111RCPP_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;
114114}
115115
116116// .External functions
117117SEXP InternalFunction_invoke (SEXP args) {
118118BEGIN_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);
123123END_RCPP
124124}
125125
126- SEXP Module__invoke (SEXP args) {
126+ SEXP Module__invoke (SEXP args) { // #nocov start
127127BEGIN_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);
131131
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);
134134END_RCPP
135- }
135+ } // #nocov end
136136
137137SEXP class__newInstance (SEXP args) {
138- SEXP p = CDR (args);
138+ SEXP p = CDR (args);
139139
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);
144144}
145145
146146// relies on being set in .onLoad()
@@ -150,78 +150,78 @@ SEXP rcpp_dummy_pointer = R_NilValue;
150150
151151
152152SEXP class__dummyInstance(SEXP args) {
153- SEXP p;
153+ SEXP p;
154154
155- if (args == R_NilValue) {
156- return rcpp_dummy_pointer;
155+ if (args == R_NilValue) {
156+ return rcpp_dummy_pointer; // #nocov
157157 }
158- p = CDR (args);
158+ p = CDR (args);
159159
160- if (p != R_NilValue) {
161- rcpp_dummy_pointer = CAR (p);
160+ if (p != R_NilValue) {
161+ rcpp_dummy_pointer = CAR (p);
162162 }
163- return rcpp_dummy_pointer;
163+ return rcpp_dummy_pointer;
164164}
165165
166- SEXP CppMethod__invoke (SEXP args) {
167- SEXP p = CDR (args);
166+ SEXP CppMethod__invoke (SEXP args) { // #nocov start
167+ SEXP p = CDR (args);
168168
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);
171171
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);
174174
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);
178178
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)
181181
182- return clazz->invoke (met, obj, cargs, nargs);
183- }
182+ return clazz->invoke (met, obj, cargs, nargs);
183+ } // #nocov end
184184
185185SEXP CppMethod__invoke_void (SEXP args) {
186- SEXP p = CDR (args);
186+ SEXP p = CDR (args);
187187
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);
190190
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);
193193
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);
197197
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;
202202}
203203
204204SEXP CppMethod__invoke_notvoid (SEXP args) {
205- SEXP p = CDR (args);
205+ SEXP p = CDR (args);
206206
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);
209209
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);
212212
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);
216216
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)
219219
220- return clazz->invoke_notvoid (met, obj, cargs, nargs);
220+ return clazz->invoke_notvoid (met, obj, cargs, nargs);
221221}
222222
223223namespace Rcpp {
224- static Module* current_scope ;
224+ static Module* current_scope ;
225225}
226226
227227Rcpp::Module* getCurrentScope () {
0 commit comments