Class: RubyPythonBridge::RubyPyClass
- Inherits:
-
RubyPyObject
- Object
- BlankObject
- 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:
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'ext/rubypython_bridge/rp_object.c', line 412
VALUE rp_mod_delegate(VALUE self,VALUE args)
{
VALUE name,name_string,rDict,result;
VALUE ret;
PObj *pDict;
PyObject *pCalled;
if(rp_equal(args))
{
return rp_mod_attr_set(self,args);
}
// if(rp_double_bang)
// {
// return rp_mod_attr_db(args);
// }
if(!rp_has_attr(self,rb_ary_entry(args,0)))
{
int argc;
VALUE *argv;
argc=RARRAY_LEN(args);
argv=ALLOC_N(VALUE,argc);
MEMCPY(argv,RARRAY_PTR(args),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
352 353 354 355 356 357 |
# File 'ext/rubypython_bridge/rp_object.c', line 352
VALUE rp_cla_new_inst(VALUE self,VALUE args)
{
PyObject *pSelf;
pSelf=rp_obj_pobject(self);
return rp_call_func(pSelf,args);
}
|