mirror of
https://github.com/boostorg/python.git
synced 2026-01-22 17:32:55 +00:00
Beginning of callback implementation
[SVN r13135]
This commit is contained in:
@@ -112,6 +112,30 @@ void function::add_to_namespace(
|
||||
throw error_already_set();
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
struct bind_return
|
||||
{
|
||||
bind_return(PyObject*& result, function const* f, PyObject* args, PyObject* keywords)
|
||||
: m_result(result)
|
||||
, m_f(f)
|
||||
, m_args(args)
|
||||
, m_keywords(keywords)
|
||||
{}
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
m_result = m_f->call(m_args, m_keywords);
|
||||
}
|
||||
|
||||
private:
|
||||
PyObject*& m_result;
|
||||
function const* m_f;
|
||||
PyObject* m_args;
|
||||
PyObject* m_keywords;
|
||||
};
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// Stolen from Python's funcobject.c
|
||||
@@ -130,9 +154,11 @@ extern "C"
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
function_call(PyObject *func, PyObject *arg, PyObject *kw)
|
||||
function_call(PyObject *func, PyObject *args, PyObject *kw)
|
||||
{
|
||||
return static_cast<function*>(func)->call(arg, kw);
|
||||
PyObject* result = 0;
|
||||
handle_exception(bind_return(result, static_cast<function*>(func), args, kw));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user