class PyCall::PyTypePtr

PyCall::PyTypePtr

Public Instance Methods

<(p1) click to toggle source
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;
}
===(p1) click to toggle source
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__() click to toggle source
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__() click to toggle source
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__() click to toggle source
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__() click to toggle source
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;
}