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



590
591
592
593
594
595
596
597
598
599
600
601
602
# File 'ext/pycall/pycall.c', line 590

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



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

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



539
540
541
542
543
544
545
546
# File 'ext/pycall/pycall.c', line 539

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



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

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



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

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



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

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