Skip to content

Commit 013ae6a

Browse files
committed
more #nocov
1 parent 1850d8c commit 013ae6a

File tree

3 files changed

+122
-123
lines changed

3 files changed

+122
-123
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* inst/include/Rcpp/exceptions.h: Added more #nocov tags
44
* inst/include/Rcpp/api/bones/wrap_extra_steps.h: Idem
55
* inst/include/Rcpp/iostream/Rstreambuf.h: Idem
6+
* inst/include/Rcpp/traits/named_object.h: Idem
67
* inst/include/Rcpp/r_cast.h: Idem
78
* src/Module.cpp: Idem
89

inst/include/Rcpp/traits/named_object.h

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
1+
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
22
/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
33
//
44
// named_object.h: Rcpp R/C++ interface class library -- named SEXP
55
//
6-
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
6+
// Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
77
//
88
// This file is part of Rcpp.
99
//
@@ -32,36 +32,34 @@ template <typename T> struct needs_protection : false_type{} ;
3232
template <> struct needs_protection<SEXP> : true_type{} ;
3333

3434
template <typename T> class named_object {
35-
public:
36-
named_object( const std::string& name_, const T& o_) :
37-
name(name_), object(o_){}
38-
const std::string& name ;
39-
const T& object ;
40-
} ;
41-
template <> class named_object<SEXP> {
4235
public:
43-
named_object( const std::string& name_, const SEXP& o_):
44-
name(name_), object(o_)
45-
{
46-
R_PreserveObject(object) ;
47-
}
36+
named_object( const std::string& name_, const T& o_) :
37+
name(name_), object(o_){}
38+
const std::string& name;
39+
const T& object;
40+
};
41+
template <> class named_object<SEXP> {
42+
public: // #nocov start
43+
named_object( const std::string& name_, const SEXP& o_):
44+
name(name_), object(o_) {
45+
R_PreserveObject(object);
46+
}
4847

49-
named_object( const named_object<SEXP>& other ) :
50-
name(other.name), object(other.object)
51-
{
52-
R_PreserveObject(object) ;
53-
}
54-
~named_object(){
55-
R_ReleaseObject(object) ;
56-
}
57-
const std::string& name ;
58-
SEXP object ;
59-
} ;
48+
named_object( const named_object<SEXP>& other ) :
49+
name(other.name), object(other.object) {
50+
R_PreserveObject(object);
51+
}
52+
~named_object() {
53+
R_ReleaseObject(object)
54+
} // #nocov end
55+
const std::string& name;
56+
SEXP object;
57+
};
6058

6159

62-
template <typename T> struct is_named : public false_type{} ;
63-
template <typename T> struct is_named< named_object<T> > : public true_type {} ;
64-
template <> struct is_named< Rcpp::Argument > : public true_type {} ;
60+
template <typename T> struct is_named : public false_type{};
61+
template <typename T> struct is_named< named_object<T> > : public true_type {};
62+
template <> struct is_named< Rcpp::Argument > : public true_type {};
6563

6664
} // namespace traits
6765
} // namespace Rcpp

src/Module.cpp

Lines changed: 95 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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) {
3434
RCPP_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
}
4040
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);
4242
}
4343
RCPP_FUN_1(std::string, Class__name, XP_Class cl) {
44-
return cl->name;
44+
return cl->name;
4545
}
4646
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);
4848
}
4949
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
5252
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);
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
}
5858
RCPP_FUN_1(Rcpp::CharacterVector, CppClass__methods, XP_Class cl) {
59-
return cl->method_names();
59+
return cl->method_names();
6060
}
6161
RCPP_FUN_1(Rcpp::CharacterVector, CppClass__properties, XP_Class cl) {
62-
return cl->property_names();
62+
return cl->property_names();
6363
}
6464
RCPP_FUN_1(Rcpp::List, CppClass__property_classes, XP_Class cl) {
65-
return cl->property_classes();
65+
return cl->property_classes();
6666
}
6767

6868
RCPP_FUN_1(Rcpp::IntegerVector, CppClass__methods_arity, XP_Class cl) {
69-
return cl->methods_arity();
69+
return cl->methods_arity();
7070
}
7171
RCPP_FUN_1(Rcpp::LogicalVector, CppClass__methods_voidness, XP_Class cl) {
72-
return cl->methods_voidness();
72+
return cl->methods_voidness();
7373
}
7474

7575

7676
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);
7878
}
7979
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);
8181
}
8282

8383
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
8686
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();
9188
}
89+
RCPP_FUN_1(std::string, Module__name, XP_Module module) { // #nocov start
90+
return module->name;
91+
} // #nocov end
9292
RCPP_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
}
9898
RCPP_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
104104
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);
106106
}
107107
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;
110110
}
111111
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;
114114
}
115115

116116
// .External functions
117117
SEXP InternalFunction_invoke(SEXP args) {
118118
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);
123123
END_RCPP
124124
}
125125

126-
SEXP Module__invoke(SEXP args) {
126+
SEXP Module__invoke(SEXP args) { // #nocov start
127127
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);
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);
134134
END_RCPP
135-
}
135+
} // #nocov end
136136

137137
SEXP 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

152152
SEXP 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

185185
SEXP 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

204204
SEXP 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

223223
namespace Rcpp{
224-
static Module* current_scope ;
224+
static Module* current_scope ;
225225
}
226226

227227
Rcpp::Module* getCurrentScope() {

0 commit comments

Comments
 (0)