R-interface

This commit is contained in:
Vitor Santos Costa 2019-04-07 00:46:30 +01:00
parent cab11f5205
commit 31743139b0
3 changed files with 10 additions and 14 deletions

View File

@ -1,4 +1,3 @@
## Up until R 2.15.0, the require("methods") is needed but (now)
## triggers an warning from R CMD check
#.onLoad <- function(libname, pkgname){
@ -9,7 +8,5 @@
## For R 2.15.1 and later this also works. Note that calling loadModule() triggers
## a load action, so this does not have to be placed in .onLoad() or evalqOnLoad().
loadModule("mod_yap4r", TRUE)
loadModule("yap4r", TRUE)

View File

@ -6,10 +6,10 @@
using namespace Rcpp;
RcppExport SEXP _rcpp_module_boot_mod_yap4r();
RcppExport SEXP _rcpp_module_boot_yap4r();
static const R_CallMethodDef CallEntries[] = {
{"_rcpp_module_boot_mod_yap4r", (DL_FUNC) &_rcpp_module_boot_mod_yap4r, 0},
{"_rcpp_module_boot_yap4r", (DL_FUNC) &_rcpp_module_boot_yap4r, 0},
{NULL, NULL, 0}
};

View File

@ -76,15 +76,14 @@ bool yap4r::query(std::string p_name, GenericVector sexps,
}
bool yap4r::compile(std::string s) {
YAPTerm fs[1];
fs[0] = YAPAtomTerm(s.c_str());
return yap->mgoal(YAPApplTerm("compile", fs).term(), USER_MODULE);
YAPTerm t;
t = YAPAtomTerm(s.c_str());
return yap->mgoal(YAPApplTerm("compile", t).term(), USER_MODULE);
}
bool yap4r::library(std::string s) {
YAPTerm fs[1], l[1];
l[0] = YAPAtomTerm(s.c_str());
fs[0] = YAPApplTerm("library", l);
return yap->mgoal(YAPApplTerm("compile", fs).term(), USER_MODULE);
YAPTerm t;
t = YAPApplTerm("library", YAPAtomTerm(s.c_str()));
return yap->mgoal(YAPApplTerm("compile", t).term(), USER_MODULE);
}
bool yap4r::more() {
@ -117,7 +116,7 @@ SEXP yap4r::peek(int i) {
return term_to_sexp(Yap_InitSlot(Yap_XREGS[i]), false);
}
RCPP_MODULE(mod_yap4r) {
RCPP_MODULE(yap4r) {
class_<yap4r>("yap4r")
.constructor("create an object encapsulating a Prolog engine")
.method("query", &yap4r::query,