Class: PyCall::PyTypePtr

Inherits:
PyPtr
  • Object
show all
Defined in:
ext/pycall/pycall.c

Constant Summary

Constants inherited from PyPtr

PyCall::PyPtr::NULL

Instance Method Summary collapse

Methods inherited from PyPtr

#==, #__address__, #__ob_refcnt__, #__ob_type__, #class, decref, #eql?, #hash, incref, #initialize, #inspect, #is_a?, #kind_of?, #nil?, #none?, #null?, #object_id, sizeof

Constructor Details

This class inherits a constructor from PyCall::PyPtr

Instance Method Details

#<(other) ⇒ Object



593
594
595
596
597
598
599
600
601
602
603
604
605
# File 'ext/pycall/pycall.c', line 593

static VALUE
pycall_pytypeptr_subclass_p(VALUE obj, VALUE other)
{
  PyTypeObject* pytype = get_pytypeobj_ptr(obj);
  if (is_pycall_pyptr(other)) {
    PyTypeObject* pytype_other = try_get_pytypeobj_ptr(other);
    if (pytype_other) {
      int res =  Py_API(PyObject_IsSubclass)((PyObject *)pytype, (PyObject *)pytype_other);
      return res ? Qtrue : Qfalse;
    }
  }
  return Qfalse;
}

#===(other) ⇒ Object



585
586
587
588
589
590
591
# File 'ext/pycall/pycall.c', line 585

static VALUE
pycall_pytypeptr_eqq(VALUE obj, VALUE other)
{
  if (is_pycall_pyptr(other))
    return pycall_pyptr_is_kind_of(other, obj);
  return Qfalse;
}

#__ob_size__Object



542
543
544
545
546
547
548
549
# File 'ext/pycall/pycall.c', line 542

static VALUE
pycall_pytypeptr_get_ob_size(VALUE obj)
{
  PyTypeObject* pytype = get_pytypeobj_ptr(obj);
  if (pytype)
    return SSIZET2NUM(pytype->ob_size);
  return Qnil;
}

#__tp_basicsize__Object



563
564
565
566
567
568
569
570
571
572
# File 'ext/pycall/pycall.c', line 563

static VALUE
pycall_pytypeptr_get_tp_basicsize(VALUE obj)
{
  PyTypeObject* pytype = get_pytypeobj_ptr(obj);
  if (pytype) {
    if (Py_TYPE(pytype) == Py_API(PyType_Type))
      return SSIZET2NUM(pytype->tp_basicsize);
  }
  return Qnil;
}

#__tp_flags__Object



574
575
576
577
578
579
580
581
582
583
# File 'ext/pycall/pycall.c', line 574

static VALUE
pycall_pytypeptr_get_tp_flags(VALUE obj)
{
  PyTypeObject* pytype = get_pytypeobj_ptr(obj);
  if (pytype) {
    if (Py_TYPE(pytype) == Py_API(PyType_Type))
      return ULONG2NUM(pytype->tp_flags);
  }
  return Qnil;
}

#__tp_name__Object



551
552
553
554
555
556
557
558
559
560
561
# File 'ext/pycall/pycall.c', line 551

static VALUE
pycall_pytypeptr_get_tp_name(VALUE obj)
{
  PyTypeObject* pytype = get_pytypeobj_ptr(obj);
  if (pytype) {
    if (Py_TYPE(pytype) == Py_API(PyType_Type))
      return rb_str_new2(pytype->tp_name);
    return pycall_pyobject_to_ruby(((PyClassObject *)pytype)->cl_name);
  }
  return Qnil;
}