Skip to content

Commit b7ff753

Browse files
committed
More cpp11 i xml2_xpath.cpp
1 parent 31e7555 commit b7ff753

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/xml2_xpath.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class XmlSeeker {
4646
SEXP ret = PROTECT(Rf_allocVector(VECSXP, 0));
4747
Rf_setAttrib(ret, R_ClassSymbol, Rf_mkString("xml_missing"));
4848
UNPROTECT(1);
49+
// TODO creating an empty list doesn't work; fails test-xml_find.R:40:3
50+
// cpp11::writable::list ret;
51+
// ret.attr("class") = "xml_missing";
4952
return ret;
5053
}
5154

@@ -54,6 +57,7 @@ class XmlSeeker {
5457
{
5558
xmlNodeSet* nodes = result_->nodesetval;
5659
if (nodes == NULL || nodes->nodeNr == 0) {
60+
// TODO
5761
SEXP ret = PROTECT(Rf_allocVector(VECSXP, 0));
5862
Rf_setAttrib(ret, R_ClassSymbol, Rf_mkString("xml_missing"));
5963
UNPROTECT(1);
@@ -104,9 +108,9 @@ cpp11::sexp xpath_search(cpp11::sexp node_sxp, cpp11::sexp doc_sxp, cpp11::sexp
104108
XPtrNode node(node_sxp);
105109
XPtrDoc doc(doc_sxp);
106110
if (TYPEOF(xpath_sxp) != STRSXP) {
107-
Rf_error("XPath must be a string, received %s", Rf_type2char(TYPEOF(xpath_sxp)));
111+
cpp11::stop("XPath must be a string, received %s", Rf_type2char(TYPEOF(xpath_sxp)));
108112
}
109-
const char* xpath = CHAR(cpp11::strings(xpath_sxp)[0]);
113+
const char* xpath = cpp11::as_cpp<const char*>(xpath_sxp);
110114

111115
double num_results = num_results_sxp[0];
112116

0 commit comments

Comments
 (0)