Class: RubyPythonBridge::RubyPyClass
- Inherits:
-
RubyPyObject
- Object
- RubyPyObject
- RubyPythonBridge::RubyPyClass
- Defined in:
- lib/rubypython/wrapper_extensions.rb,
ext/rubypython_bridge/rp_object.c
Overview
A wrapper class for Python classes.
This allows objects which cannot easily be converted to native Ruby types to still be accessible from within ruby. Most users need not concern themselves with anything about this class except its existence.
Instance Method Summary collapse
Methods inherited from RubyPyObject
#__name, #free_pobj, #inspect, #respond_to?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(args) ⇒ Object
:nodoc:
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
# File 'ext/rubypython_bridge/rp_object.c', line 272
VALUE rp_mod_delegate(VALUE self,VALUE args)
{
VALUE name,name_string,rDict,result;
VALUE ret;
PObj *pDict;
PyObject *pCalled;
if(!rp_has_attr(self,rb_ary_entry(args,0)))
{
int argc;
VALUE *argv;
argc=RARRAY(args)->len;
argv=ALLOC_N(VALUE,argc);
MEMCPY(argv,RARRAY(args)->ptr,VALUE,argc);
return rb_call_super(argc,argv);
}
name=rb_ary_shift(args);
name_string=rb_funcall(name,rb_intern("to_s"),0);
rDict=rb_iv_get(self,"@pdict");
Data_Get_Struct(rDict,PObj,pDict);
pCalled=PyDict_GetItemString(pDict->pObject,STR2CSTR(name_string));
Py_XINCREF(pCalled);
result=ptor_obj_no_destruct(pCalled);
if(rb_obj_is_instance_of(result,cRubyPyFunction))
{
ret=rp_call_func(pCalled,args);
return ret;
}
else if(rb_obj_is_instance_of(result,cRubyPyClass)&&(rb_funcall(args,rb_intern("empty?"),0)==Qfalse)&&PyCallable_Check(pCalled))
{
ret=rp_call_func(pCalled,args);
return ret;
}
return result;
}
|
Instance Method Details
#new(args) ⇒ Object
256 257 258 259 260 261 |
# File 'ext/rubypython_bridge/rp_object.c', line 256
VALUE rp_cla_new_inst(VALUE self,VALUE args)
{
PyObject *pSelf;
pSelf=rp_obj_pobject(self);
return rp_call_func(pSelf,args);
}
|