MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / checkRSignature

Function checkRSignature

src/attributes.cpp:2800–2826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2798 }
2799
2800 bool checkRSignature(const Function& function,
2801 std::string args) {
2802 std::vector<std::string> required_args;
2803 const std::vector<Argument>& arguments = function.arguments();
2804 for (size_t i = 0; i<arguments.size(); i++) {
2805 const Argument& argument = arguments[i];
2806 required_args.push_back(argument.name());
2807 }
2808 args = "function(" + args + ") {}";
2809 Rcpp::Function parse = Rcpp::Environment::base_env()["parse"];
2810 Rcpp::Function eval = Rcpp::Environment::base_env()["eval"];
2811 Rcpp::Function formalArgs =
2812 Rcpp::Environment::namespace_env("methods")["formalArgs"];
2813
2814 // If signature fails to parse, allow error to fall through
2815 // as the error message is generally more descriptive
2816 CharacterVector pargs_cv = formalArgs(eval(parse(_["text"] = args)));
2817 std::vector<std::string> parsed_args =
2818 Rcpp::as<std::vector<std::string> >(pargs_cv);
2819
2820 for(size_t i=0; i<required_args.size(); ++i) {
2821 if(std::find(parsed_args.begin(), parsed_args.end(),
2822 required_args[i]) == parsed_args.end())
2823 return false;
2824 }
2825 return true;
2826 }
2827
2828 // Generate the C++ code required to initialize global objects
2829 void initializeGlobals(std::ostream& ostr) {

Callers 2

doWriteFunctionsMethod · 0.85
generateRMethod · 0.85

Calls 8

base_envFunction · 0.85
namespace_envFunction · 0.85
evalFunction · 0.85
findFunction · 0.85
sizeMethod · 0.45
push_backMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected