yap4r
This commit is contained in:
parent
0112ad9c20
commit
2f1eb61cf9
12
packages/real/yap4r/DESCRIPTION
Normal file
12
packages/real/yap4r/DESCRIPTION
Normal file
@ -0,0 +1,12 @@
|
||||
Package: yap4r
|
||||
Type: Package
|
||||
Title: What the Package Does in One 'Title Case' Line
|
||||
Version: 1.0
|
||||
Date: 2019-03-25
|
||||
Author: Your Name
|
||||
Maintainer: Your Name <your@email.com>
|
||||
Description: One paragraph description of what the package does as one
|
||||
or more full sentences.
|
||||
License: GPL (>= 2)
|
||||
Imports: Rcpp (>= 1.0.1)
|
||||
LinkingTo: Rcpp
|
3
packages/real/yap4r/NAMESPACE
Normal file
3
packages/real/yap4r/NAMESPACE
Normal file
@ -0,0 +1,3 @@
|
||||
useDynLib(yap4r, .registration=TRUE)
|
||||
exportPattern("^[[:alpha:]]+")
|
||||
importFrom(Rcpp, evalCpp)
|
19
packages/real/yap4r/R/RcppExports.R
Normal file
19
packages/real/yap4r/R/RcppExports.R
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
|
||||
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
|
||||
|
||||
query <- function(p_name, p_module, sexp) {
|
||||
.Call(`_yap4r_query`, p_name, p_module, sexp)
|
||||
}
|
||||
|
||||
next <- function() {
|
||||
.Call(`_yap4r_next`)
|
||||
}
|
||||
|
||||
cut <- function() {
|
||||
.Call(`_yap4r_cut`)
|
||||
}
|
||||
|
||||
ask <- function(i) {
|
||||
.Call(`_yap4r_ask`, i)
|
||||
}
|
||||
|
34
packages/real/yap4r/man/yap4r-package.Rd
Normal file
34
packages/real/yap4r/man/yap4r-package.Rd
Normal file
@ -0,0 +1,34 @@
|
||||
\name{yap4r-package}
|
||||
\alias{yap4r-package}
|
||||
\alias{yap4r}
|
||||
\docType{package}
|
||||
\title{
|
||||
A short title line describing what the package does
|
||||
}
|
||||
\description{
|
||||
A more detailed description of what the package does. A length
|
||||
of about one to five lines is recommended.
|
||||
}
|
||||
\details{
|
||||
This section should provide a more detailed overview of how to use the
|
||||
package, including the most important functions.
|
||||
}
|
||||
\author{
|
||||
Your Name, email optional.
|
||||
|
||||
Maintainer: Your Name <your@email.com>
|
||||
}
|
||||
\references{
|
||||
This optional section can contain literature or other references for
|
||||
background information.
|
||||
}
|
||||
\keyword{ package }
|
||||
\seealso{
|
||||
Optional links to other man pages
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
## Optional simple examples of the most important functions
|
||||
## These can be in \dontrun{} and \donttest{} blocks.
|
||||
}
|
||||
}
|
2
packages/real/yap4r/src/Makevars.in
Normal file
2
packages/real/yap4r/src/Makevars.in
Normal file
@ -0,0 +1,2 @@
|
||||
PKG_LIBS=-L/home/vsc/.local/lib/Yap/ -lreal
|
||||
PKG_CPPFLAGS=-I../../../../CXX -I../../../../build -I../../../../include -I../../../../H -I../../../../OPTYap -I../../../../os -I../..
|
67
packages/real/yap4r/src/RcppExports.cpp
Normal file
67
packages/real/yap4r/src/RcppExports.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
// Generated by using Rcpp::compileAttributes() -> do not edit by hand
|
||||
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
|
||||
|
||||
#include <Rcpp.h>
|
||||
|
||||
using namespace Rcpp;
|
||||
|
||||
// query
|
||||
bool query(std::string p_name, std::string p_module, SEXP sexp);
|
||||
RcppExport SEXP _yap4r_query(SEXP p_nameSEXP, SEXP p_moduleSEXP, SEXP sexpSEXP) {
|
||||
BEGIN_RCPP
|
||||
Rcpp::RObject rcpp_result_gen;
|
||||
Rcpp::RNGScope rcpp_rngScope_gen;
|
||||
Rcpp::traits::input_parameter< std::string >::type p_name(p_nameSEXP);
|
||||
Rcpp::traits::input_parameter< std::string >::type p_module(p_moduleSEXP);
|
||||
Rcpp::traits::input_parameter< SEXP >::type sexp(sexpSEXP);
|
||||
rcpp_result_gen = Rcpp::wrap(query(p_name, p_module, sexp));
|
||||
return rcpp_result_gen;
|
||||
END_RCPP
|
||||
}
|
||||
// next
|
||||
bool next();
|
||||
RcppExport SEXP _yap4r_next() {
|
||||
BEGIN_RCPP
|
||||
Rcpp::RObject rcpp_result_gen;
|
||||
Rcpp::RNGScope rcpp_rngScope_gen;
|
||||
rcpp_result_gen = Rcpp::wrap(next());
|
||||
return rcpp_result_gen;
|
||||
END_RCPP
|
||||
}
|
||||
// cut
|
||||
bool cut();
|
||||
RcppExport SEXP _yap4r_cut() {
|
||||
BEGIN_RCPP
|
||||
Rcpp::RObject rcpp_result_gen;
|
||||
Rcpp::RNGScope rcpp_rngScope_gen;
|
||||
rcpp_result_gen = Rcpp::wrap(cut());
|
||||
return rcpp_result_gen;
|
||||
END_RCPP
|
||||
}
|
||||
// ask
|
||||
SEXP ask(int i);
|
||||
RcppExport SEXP _yap4r_ask(SEXP iSEXP) {
|
||||
BEGIN_RCPP
|
||||
Rcpp::RObject rcpp_result_gen;
|
||||
Rcpp::RNGScope rcpp_rngScope_gen;
|
||||
Rcpp::traits::input_parameter< int >::type i(iSEXP);
|
||||
rcpp_result_gen = Rcpp::wrap(ask(i));
|
||||
return rcpp_result_gen;
|
||||
END_RCPP
|
||||
}
|
||||
|
||||
RcppExport SEXP _rcpp_module_boot_mod_yap4r();
|
||||
|
||||
static const R_CallMethodDef CallEntries[] = {
|
||||
{"_yap4r_query", (DL_FUNC) &_yap4r_query, 3},
|
||||
{"_yap4r_next", (DL_FUNC) &_yap4r_next, 0},
|
||||
{"_yap4r_cut", (DL_FUNC) &_yap4r_cut, 0},
|
||||
{"_yap4r_ask", (DL_FUNC) &_yap4r_ask, 1},
|
||||
{"_rcpp_module_boot_mod_yap4r", (DL_FUNC) &_rcpp_module_boot_mod_yap4r, 0},
|
||||
{NULL, NULL, 0}
|
||||
};
|
||||
|
||||
RcppExport void R_init_yap4r(DllInfo *dll) {
|
||||
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
|
||||
R_useDynamicSymbols(dll, FALSE);
|
||||
}
|
93
packages/real/yap4r/src/yap4r.cpp
Normal file
93
packages/real/yap4r/src/yap4r.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
#include <Rcpp.h>
|
||||
|
||||
#undef Realloc
|
||||
#undef Malloc
|
||||
#undef Free
|
||||
#include <yapi.hh>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "real.h"
|
||||
|
||||
|
||||
using namespace Rcpp;
|
||||
|
||||
class YAP4R {
|
||||
|
||||
YAPEngine *yap;
|
||||
YAPQuery *q;
|
||||
std::vector<YAPTerm> args;
|
||||
bool failed;
|
||||
|
||||
public:
|
||||
//[[Rcpp::export]]
|
||||
|
||||
YAP4R() {
|
||||
YAPEngineArgs *yargs = new YAPEngineArgs();
|
||||
yap = new YAPEngine(yargs);
|
||||
};
|
||||
|
||||
|
||||
//[[Rcpp::export]]
|
||||
bool query(std::string p_name,std::string p_module, SEXP sexp) {
|
||||
|
||||
YAPPairTerm tmp;
|
||||
if (q) {
|
||||
q->close();
|
||||
q = NULL;
|
||||
}
|
||||
if (!sexp_to_pl(tmp.handle(), sexp))
|
||||
return false;
|
||||
args = tmp.listToVector();
|
||||
YAPTerm ts[1], hd;
|
||||
YAPTerm qt = YAPApplTerm(p_name,args);
|
||||
q = new YAPQuery(qt);
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
//[[Rcpp::export]]
|
||||
bool next() {
|
||||
bool rc = true;
|
||||
if (failed)
|
||||
return false;
|
||||
if (q)
|
||||
rc = next();
|
||||
if (!rc) {
|
||||
failed = true;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
//[[Rcpp::export]]
|
||||
bool cut() {
|
||||
bool rc = true;
|
||||
if (failed)
|
||||
return false;
|
||||
if (q)
|
||||
rc = cut();
|
||||
q = NULL;
|
||||
return rc;
|
||||
};
|
||||
|
||||
//[[Rcpp::export]]
|
||||
SEXP ask(int i) {
|
||||
if (failed || q==nullptr)
|
||||
return R_MissingArg;
|
||||
return term_to_sexp(YAPTerm(Yap_XREGS[i]).handle(), false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
RCPP_MODULE(mod_yap4r) {
|
||||
Rcpp::class_<YAP4R>( "YAP4R" )
|
||||
.constructor("documentation for default constructor")
|
||||
.method( "query", &YAP4R::query )
|
||||
.method( "next", &YAP4R::next )
|
||||
.method( "ask", &YAP4R::ask )
|
||||
.method( "cut", &YAP4R::cut )
|
||||
;
|
||||
;
|
||||
}
|
Reference in New Issue
Block a user