| 3419 | } |
| 3420 | |
| 3421 | void generateR(std::ostream& ostr, |
| 3422 | const SourceFileAttributes& attributes, |
| 3423 | const std::string& dllInfo) const |
| 3424 | { |
| 3425 | // process each attribute |
| 3426 | for(std::vector<Attribute>::const_iterator |
| 3427 | it = attributes.begin(); it != attributes.end(); ++it) { |
| 3428 | |
| 3429 | // alias the attribute and function (bail if not export) |
| 3430 | const Attribute& attribute = *it; |
| 3431 | if (!attribute.isExportedFunction()) |
| 3432 | continue; |
| 3433 | const Function& function = attribute.function(); |
| 3434 | |
| 3435 | // build the parameter list |
| 3436 | std::string args = generateRArgList(function); |
| 3437 | |
| 3438 | // check if has a custom signature |
| 3439 | if(attribute.hasParameter(kExportSignature)) { |
| 3440 | args = attribute.customRSignature(); |
| 3441 | if(!checkRSignature(function, args)) { |
| 3442 | std::string rsig_err_msg = "Missing args in " + args; |
| 3443 | throw Rcpp::exception(rsig_err_msg.c_str()); |
| 3444 | } |
| 3445 | } |
| 3446 | |
| 3447 | // export the function |
| 3448 | ostr << attribute.exportedName() |
| 3449 | << " <- Rcpp:::sourceCppFunction(" |
| 3450 | << "function(" << args << ") {}, " |
| 3451 | << (function.type().isVoid() ? "TRUE" : "FALSE") << ", " |
| 3452 | << dllInfo << ", " |
| 3453 | << "'" << contextId_ + "_" + function.name() |
| 3454 | << "')" << std::endl; |
| 3455 | } |
| 3456 | |
| 3457 | // modules |
| 3458 | std::vector<std::string> modules = attributes.modules(); |
| 3459 | if (modules.size() > 0) |
| 3460 | { |
| 3461 | // modules require definition of C++Object to be loaded |
| 3462 | ostr << "library(Rcpp)" << std::endl; |
| 3463 | |
| 3464 | // load each module |
| 3465 | for (std::vector<std::string>::const_iterator |
| 3466 | it = modules.begin(); it != modules.end(); ++it) |
| 3467 | { |
| 3468 | ostr << " populate( Rcpp::Module(\"" << *it << "\"," |
| 3469 | << dllInfo << "), environment() ) " << std::endl; |
| 3470 | } |
| 3471 | } |
| 3472 | |
| 3473 | } |
| 3474 | |
| 3475 | std::string uniqueToken(const std::string& cacheDir) { |
| 3476 | Rcpp::Environment rcppEnv = Rcpp::Environment::namespace_env("Rcpp"); |
nothing calls this directly
no test coverage detected