Class: RubyPythonBridge::RubyPyObject

Inherits:
Object
  • Object
show all
Defined in:
ext/rubypython_bridge/rp_object.c,
lib/rubypython/wrapper_extensions.rb

Instance Method Summary collapse

Instance Method Details

#__nameObject

Returns the name of the Python object which this instance wraps.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'ext/rubypython_bridge/rp_object.c', line 71

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_pobjObject

Decreases the reference count on the object wrapped by this instance. This is used for cleanup in RubyPython.stop. RubyPyObject instance automatically decrease the reference count on their associated objects before they are garbage collected.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'ext/rubypython_bridge/rp_object.c', line 31

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;
}

#inspectObject



2
3
4
# File 'lib/rubypython/wrapper_extensions.rb', line 2

def inspect
  "<#{self.class}:#{__name}>"
end

#respond_to?(mname) ⇒ Boolean

Returns:

  • (Boolean)


263
264
265
266
267
268
269
270
# File 'ext/rubypython_bridge/rp_object.c', line 263

VALUE rp_obj_responds(VALUE self,VALUE mname)
{
	if(rp_has_attr(self,mname))
	{
		return Qtrue;
	}
	return Qfalse;
}