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



544
545
546
547
548
549
550
551
552
553
554
555
556
# File 'ext/pycall/pycall.c', line 544

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



536
537
538
539
540
541
542
# File 'ext/pycall/pycall.c', line 536

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



493
494
495
496
497
498
499
500
# File 'ext/pycall/pycall.c', line 493

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



514
515
516
517
518
519
520
521
522
523
# File 'ext/pycall/pycall.c', line 514

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



525
526
527
528
529
530
531
532
533
534
# File 'ext/pycall/pycall.c', line 525

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



502
503
504
505
506
507
508
509
510
511
512
# File 'ext/pycall/pycall.c', line 502

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