R-interface
This commit is contained in:
parent
cab11f5205
commit
31743139b0
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
## Up until R 2.15.0, the require("methods") is needed but (now)
|
## Up until R 2.15.0, the require("methods") is needed but (now)
|
||||||
## triggers an warning from R CMD check
|
## triggers an warning from R CMD check
|
||||||
#.onLoad <- function(libname, pkgname){
|
#.onLoad <- function(libname, pkgname){
|
||||||
@ -9,7 +8,5 @@
|
|||||||
|
|
||||||
## For R 2.15.1 and later this also works. Note that calling loadModule() triggers
|
## 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().
|
## a load action, so this does not have to be placed in .onLoad() or evalqOnLoad().
|
||||||
loadModule("mod_yap4r", TRUE)
|
loadModule("yap4r", TRUE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
using namespace Rcpp;
|
using namespace Rcpp;
|
||||||
|
|
||||||
|
|
||||||
RcppExport SEXP _rcpp_module_boot_mod_yap4r();
|
RcppExport SEXP _rcpp_module_boot_yap4r();
|
||||||
|
|
||||||
static const R_CallMethodDef CallEntries[] = {
|
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}
|
{NULL, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -76,15 +76,14 @@ bool yap4r::query(std::string p_name, GenericVector sexps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool yap4r::compile(std::string s) {
|
bool yap4r::compile(std::string s) {
|
||||||
YAPTerm fs[1];
|
YAPTerm t;
|
||||||
fs[0] = YAPAtomTerm(s.c_str());
|
t = YAPAtomTerm(s.c_str());
|
||||||
return yap->mgoal(YAPApplTerm("compile", fs).term(), USER_MODULE);
|
return yap->mgoal(YAPApplTerm("compile", t).term(), USER_MODULE);
|
||||||
}
|
}
|
||||||
bool yap4r::library(std::string s) {
|
bool yap4r::library(std::string s) {
|
||||||
YAPTerm fs[1], l[1];
|
YAPTerm t;
|
||||||
l[0] = YAPAtomTerm(s.c_str());
|
t = YAPApplTerm("library", YAPAtomTerm(s.c_str()));
|
||||||
fs[0] = YAPApplTerm("library", l);
|
return yap->mgoal(YAPApplTerm("compile", t).term(), USER_MODULE);
|
||||||
return yap->mgoal(YAPApplTerm("compile", fs).term(), USER_MODULE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool yap4r::more() {
|
bool yap4r::more() {
|
||||||
@ -117,7 +116,7 @@ SEXP yap4r::peek(int i) {
|
|||||||
return term_to_sexp(Yap_InitSlot(Yap_XREGS[i]), false);
|
return term_to_sexp(Yap_InitSlot(Yap_XREGS[i]), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
RCPP_MODULE(mod_yap4r) {
|
RCPP_MODULE(yap4r) {
|
||||||
class_<yap4r>("yap4r")
|
class_<yap4r>("yap4r")
|
||||||
.constructor("create an object encapsulating a Prolog engine")
|
.constructor("create an object encapsulating a Prolog engine")
|
||||||
.method("query", &yap4r::query,
|
.method("query", &yap4r::query,
|
||||||
|
Reference in New Issue
Block a user