Class: RubyPythonBridge::RubyPyObject

Inherits:
BlankObject 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.



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
130
# File 'ext/rubypython_bridge/rp_object.c', line 97

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 instances automatically decrease the reference count on their associated objects before they are garbage collected.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'ext/rubypython_bridge/rp_object.c', line 57

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



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

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

#respond_to?(mname) ⇒ Boolean

Returns:

  • (Boolean)


360
361
362
363
364
365
366
367
# File 'ext/rubypython_bridge/rp_object.c', line 360

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