PyInstanceClass::FactoryCreate#
-
static inline PyInstanceClass YR::PyInstanceClass::FactoryCreate(const std::string &moduleName, const std::string &className)#
Creates a
PyInstanceClassobject, which can be passed as a parameter toYR::Instanceto successfully create a Python function class instance.int main(void) { // class Instance: // sum = 0 // // def __init__(self, init): // self.sum = init // // def add(self, a): // self.sum += a // // def get(self): // return self.sum YR::Config conf; YR::Init(conf); auto pyInstance = YR::PyInstanceClass::FactoryCreate("pycallee", "Instance"); // moduleName, className auto r1 = YR::Instance(pyInstance).Invoke(x); r1.PyFunction<void>("add").Invoke(1); // returnType, memberFunctionName auto r2 = r1.PyFunction<int>("get").Invoke(); auto res = *YR::Get(r2); std::cout << "PlusOneWithPyClass with result=" << res << std::endl; return res; return 0; }
- Parameters:
moduleName – The name of the Python module.
className – The name of the Python class.
- Returns:
Returns a
PyInstanceClassobject carrying function information, which can be passed as a parameter toYR::Instance.