Say I have this struct:
typedef struct
{
PyObject_HEAD
Foo* myFoo;
} PyFoo;
Let's just say that Foo
is:
class Foo
{
public:
hello()
{
std::cout << "Hello\n";
}
};
I don't want to remake class Foo as a python module because it represents a class from a library with a lot more functions and variables (but that isn't relevant to this question). I didn't really understand from the docs how to create a PyObject* in C/C++ with arguments, much less how to do it with C/C++ pointers as arguments.
I am going off this guide: https://docs.python.org/3/extending/newtypes_tutorial.html
I do have my dealloc, new, and init methods from the guide, but I have not tried to initialize and deallocate any values, except for the instance of the object itself.
This question is similar to Build a PyObject* from a C function? but I want to pass an object pointer instead of a function. I am using the same method as Create an object using Python's C API to create the object, but I don't know how I can give an instance of foo to the PyObject.