Begin templating

This commit is contained in:
2023-10-30 22:45:35 +01:00
parent e26acc3676
commit 77c33942f6
9 changed files with 64 additions and 16 deletions

View File

@@ -83,7 +83,8 @@ namespace pywrap {
PyErr_Print();
exit(1);
}
void PyWrap::callMethod(const std::string& moduleName, const std::string& className, const std::string& method)
template<typename T>
T PyWrap::callMethod(const std::string& moduleName, const std::string& className, const std::string& method)
{
std::cout << "Llamando método" << std::endl;
auto item = moduleClassMap.find({ moduleName, className });
@@ -95,8 +96,11 @@ namespace pywrap {
PyObject* result;
if (!(result = PyObject_CallMethod(instance, method.c_str(), NULL)))
errorAbort("Couldn't call method " + method);
std::cout << "Result: " << PyUnicode_AsUTF8(result) << std::endl;
T value = PyUnicode_AsUTF8(result);
std::cout << "Result: " << value << std::endl;
Py_DECREF(result);
return value;
}
// void PyWrap::doCommand2()
// {