ext/redrat_ext/redrat_ext.c
/*
 * redrat_python_handoff - Hands off a Ruby VALUE to Python
 *
 * If this PyObject is of type 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, Python
 * will get its own global variable reference (via rb_gc_register_address) and
 * in the destructor for a RubyObject the inverse, rb_gc_unregister_address
 * must be called.
 */
Hands off a Ruby VALUE to Python
If this PyObject is of type 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, Python
will get its own global variable reference (via rb_gc_register_address) and
in the destructor for a RubyObject the inverse, rb_gc_unregister_address
must be called.
Hands off a Ruby VALUE to Python If this PyObject is of type 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 Python will get its own global variable reference ( via rb_gc_register_address ) and in the destructor for a RubyObject the inverse rb_gc_unregister_address must be called .
static PyObject *
redrat_python_handoff(VALUE r)
{
    if (REDRAT_PYTHONVALUE_P(r))
    {
        PyObject *ret;
        Data_Get_Struct(r, PyObject, ret);
        return ret;
    }
    else
    {
        redrat_RubyObject *pyr;
        rb_gc_register_address(&r);
        pyr = (void *) redrat_RubyType.tp_alloc(&redrat_RubyType, 0);
        pyr->r = r;
        return (PyObject *) pyr;
    }
}
static PyObject * redrat_python_handoff ( VALUE r ) { if ( REDRAT_PYTHONVALUE_P ( r ) ) { PyObject * ret ; Data_Get_Struct ( r , PyObject , ret ) ; return ret ; } else { redrat_RubyObject * pyr ; rb_gc_register_address ( & r ) ; pyr = ( void * ) redrat_RubyType . tp_alloc ( & redrat_RubyType , 0 ) ; pyr -> r = r ; return ( PyObject * ) pyr ; } }
redrat_python_handoff - Hands off a Ruby VALUE to Python
 If this PyObject is of type RubyObject, then just return the unwrapped Ruby
 object inside.
redrat_python_handoff - Hands off a Ruby VALUE to Python If this PyObject is of type RubyObject then just return the unwrapped Ruby object inside .
/*
         * Notify Ruby that this value has a reference somewhere otherwise
         * unknown to its mark-sweep collection pass, as so the value does not
         * get GCed while Python has references still.
         */