PyFunction#
-
template<typename R>
class PyFunctionHandler : public YR::internal::CrossLangBaseType# - Template Parameters:
R – return value type
-
template<typename R>
FunctionHandler<PyFunctionHandler<R>> YR::PyFunction(const std::string &moduleName, const std::string &functionName)# Used for C++ to call Python functions, constructs a call to a Python function.
int main(void) { // def add_one(a): // return a + 1 YR::Config conf; YR::Init(conf); auto r1 = YR::PyFunction<int>("pycallee", "add_one").Invoke(x); // moduleName, functionName auto res = *YR::Get(r1); std::cout << "PlusOneWithPyFunc with result=" << res << std::endl; return res; return 0; }
- Template Parameters:
R – The return type of the function.
- Parameters:
moduleName – The name of the Python module where the function resides.
functionName – The name of the Python function.
- Returns:
A
FunctionHandlerobject, which provides methods to execute the function. ThePyFunctionHandleris a template class withinFunctionHandlerthat can be used to obtain the return type.