ext/redrat_ext/redrat_ext.c
/*
 * redrat_ruby_handoff - Hands off a PyObject to Ruby
 *
 * If this PyObject is of type redrat.RubyObject, then just return the
 * unwrapped Ruby object inside.
 *
 * This procedure presumes that the Python GIL and Ruby GILs are already held.
 *
 * This includes the hybridization of Ruby and Python GC.  To do this, Ruby
 * will get its own reference (Py_INCREF) and registers a callback that exists
 * to call Py_DECREF.  In this way, a PythonValue that has no remaining
 * references in the Python runtime will still not be freed, since Ruby has not
 * GCed it yet.
 */
Hands off a PyObject to Ruby
If this PyObject is of type redrat.RubyObject, then just return the
unwrapped Ruby object inside.

This procedure presumes that the Python GIL and Ruby GILs are already held.

This includes the hybridization of Ruby and Python GC.  To do this, Ruby
will get its own reference (Py_INCREF) and registers a callback that exists
to call Py_DECREF.  In this way, a PythonValue that has no remaining
references in the Python runtime will still not be freed, since Ruby has not
GCed it yet.
Hands off a PyObject to Ruby If this PyObject is of type redrat . RubyObject then just return the unwrapped Ruby object inside . This procedure presumes that the Python GIL and Ruby GILs are already held . This includes the hybridization of Ruby and Python GC . To do this Ruby will get its own reference ( Py_INCREF ) and registers a callback that exists to call Py_DECREF . In this way a PythonValue that has no remaining references in the Python runtime will still not be freed since Ruby has not GCed it yet .
static VALUE
redrat_ruby_handoff(PyObject *handing_off)
{
    if (handing_off->ob_type == &redrat_RubyType)
        return ((redrat_RubyObject *) handing_off)->r;
    else
    {
        Py_INCREF(handing_off);
        return Data_Wrap_Struct(rb_cPythonValue,
                                NULL, redrat_py_decref_wrap,
                                handing_off);
    }
}
static VALUE redrat_ruby_handoff ( PyObject * handing_off ) { if ( handing_off -> ob_type == & redrat_RubyType ) return ( ( redrat_RubyObject * ) handing_off ) -> r ; else { Py_INCREF ( handing_off ) ; return Data_Wrap_Struct ( rb_cPythonValue , NULL , redrat_py_decref_wrap , handing_off ) ; } }
redrat_ruby_handoff - Hands off a PyObject to Ruby
 If this PyObject is of type redrat.RubyObject, then just return the
 unwrapped Ruby object inside.
redrat_ruby_handoff - Hands off a PyObject to Ruby If this PyObject is of type redrat . RubyObject then just return the unwrapped Ruby object inside .