Add a dummy pass-through conversion for already converted python objects

This commit is contained in:
baldurk
2018-10-23 14:23:12 +01:00
parent 789c3b9333
commit 67fc971cd9
2 changed files with 24 additions and 0 deletions
@@ -57,6 +57,9 @@ public:
static void ProcessExtensionWork(std::function<void()> callback);
static bool LoadExtension(ICaptureContext &ctx, const rdcstr &extension);
static void ConvertPyArgs(const ExtensionCallbackData &data,
rdcarray<rdcpair<rdcstr, PyObject *>> &args);
static void FreePyArgs(rdcarray<rdcpair<rdcstr, PyObject *>> &args);
bool CheckInterfaces();
@@ -71,6 +71,27 @@ struct TypeConversion
}
};
// specialisations for Python object that just increments the refcount. Only useful if we're doing
// something quite special and manually converting outside from some type we don't want to expose to
// python (this is used for QVariant conversion in python callback arguments).
template <>
struct TypeConversion<PyObject *, false>
{
static int ConvertFromPy(PyObject *in, PyObject *&out)
{
out = in;
Py_XINCREF(out);
return 0;
}
static PyObject *ConvertToPy(PyObject *in)
{
Py_XINCREF(in);
return in;
}
};
// specialisations for pointer types (opaque handles to be moved not copied)
template <typename Opaque>
struct TypeConversion<Opaque *, false>