Class: RubyPythonBridge::RubyPyObject
- Inherits:
-
BlankObject
- Object
- BlankObject
- RubyPythonBridge::RubyPyObject
- Defined in:
- ext/rubypython_bridge/rp_object.c,
lib/rubypython/wrapper_extensions.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#__name ⇒ Object
Returns the name of the Python object which this instance wraps.
-
#free_pobj ⇒ Object
Decreases the reference count on the object wrapped by this instance.
- #inspect ⇒ Object
- #respond_to?(mname) ⇒ Boolean
Instance Method Details
#__name ⇒ Object
Returns the name of the Python object which this instance wraps.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'ext/rubypython_bridge/rp_object.c', line 96
VALUE rp_obj_name(VALUE self)
{
if(Py_IsInitialized())
{
PyObject *pObject,*pName,*pRepr;
VALUE rName;
pObject=rp_obj_pobject(self);
pName=PyObject_GetAttrString(pObject,"__name__");
if(!pName)
{
PyErr_Clear();
pName=PyObject_GetAttrString(pObject,"__class__");
pRepr=PyObject_Repr(pName);
rName=ptor_string(pRepr);
Py_XDECREF(pRepr);
return rb_str_concat(rb_str_new2("An instance of "),rName);
if(!pName)
{
PyErr_Clear();
pName=PyObject_Repr(pObject);
if(!pName)
{
PyErr_Clear();
return rb_str_new2("__Unnameable__");
}
}
}
rName=ptor_string(pName);
Py_XDECREF(pName);
return rName;
}
return rb_str_new2("__FREED__");
}
|
#free_pobj ⇒ Object
Decreases the reference count on the object wrapped by this instance. This is used for cleanup in RubyPython.stop. RubyPyObject instances automatically decrease the reference count on their associated objects before they are garbage collected.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'ext/rubypython_bridge/rp_object.c', line 56
VALUE rp_obj_free_pobj(VALUE self)
{
PObj *cself;
Data_Get_Struct(self,PObj,cself);
if(Py_IsInitialized()&&cself->pObject)
{
Py_XDECREF(cself->pObject);
cself->pObject=NULL;
return Qtrue;
}
else
{
cself->pObject=NULL;
}
return Qfalse;
}
|
#inspect ⇒ Object
3 4 5 |
# File 'lib/rubypython/wrapper_extensions.rb', line 3 def inspect "<#{self.class}:#{__name}>" end |
#respond_to?(mname) ⇒ Boolean
359 360 361 362 363 364 365 366 |
# File 'ext/rubypython_bridge/rp_object.c', line 359
VALUE rp_obj_responds(VALUE self,VALUE mname)
{
if(rp_has_attr(self,mname))
{
return Qtrue;
}
return Qfalse;
}
|