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



601
602
603
604
605
606
607
608
609
610
611
612
613
# File 'ext/pycall/pycall.c', line 601

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



593
594
595
596
597
598
599
# File 'ext/pycall/pycall.c', line 593

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



550
551
552
553
554
555
556
557
# File 'ext/pycall/pycall.c', line 550

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



571
572
573
574
575
576
577
578
579
580
# File 'ext/pycall/pycall.c', line 571

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



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

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



559
560
561
562
563
564
565
566
567
568
569
# File 'ext/pycall/pycall.c', line 559

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