How do I pass the calling C++ class reference (or anything) to a callback?
My code is:
static PyObject*
emb_Set(PyObjec t *self, PyObject *args)
{
char *key, *value;
if(!PyArg_Parse Tuple(args, "ss", &key, &value))
return NULL;
// do something with the C++ class here
// how the get the class instance pointer?
Py_INCREF(Py_No ne);
return Py_None;
}
static PyMethodDef EmbMethods[] = {
{"Set", emb_Set, METH_VARARGS, "Sets the given variable."},
{NULL, NULL, 0, NULL}
};
in C++ class:
Py_Initialize() ;
Py_InitModule(" test", EmbMethods);
PyRun_SimpleStr ing(script);
Py_Finalize();
Harri
My code is:
static PyObject*
emb_Set(PyObjec t *self, PyObject *args)
{
char *key, *value;
if(!PyArg_Parse Tuple(args, "ss", &key, &value))
return NULL;
// do something with the C++ class here
// how the get the class instance pointer?
Py_INCREF(Py_No ne);
return Py_None;
}
static PyMethodDef EmbMethods[] = {
{"Set", emb_Set, METH_VARARGS, "Sets the given variable."},
{NULL, NULL, 0, NULL}
};
in C++ class:
Py_Initialize() ;
Py_InitModule(" test", EmbMethods);
PyRun_SimpleStr ing(script);
Py_Finalize();
Harri
Comment