Module: PyCall::LibPython::API

Defined in:
ext/pycall/pycall.c

Class Method Summary collapse

Class Method Details

.builtins_module_ptrObject

PyCall::LibPython::API ====



606
607
608
609
610
611
612
# File 'ext/pycall/pycall.c', line 606

static VALUE
pycall_libpython_api_get_builtins_module_ptr(VALUE mod)
{
  VALUE pyptr = pycall_pyptr_new(python_builtins_module);
  Py_API(Py_IncRef)(python_builtins_module);
  return pyptr;
}

.PyList_GetItem(pyptr, idx) ⇒ Object



652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
# File 'ext/pycall/pycall.c', line 652

static VALUE
pycall_libpython_api_PyList_GetItem(VALUE mod, VALUE pyptr, VALUE idx)
{
  PyObject *pyobj;
  PyObject *pyobj_item;
  Py_ssize_t i;

  if (!is_pycall_pyptr(pyptr)) {
    rb_raise(rb_eTypeError, "PyCall::PyPtr is required");
  }

  pyobj = get_pyobj_ptr(pyptr);
  i = NUM2SSIZET(idx);
  pyobj_item = Py_API(PyList_GetItem)(pyobj, i);
  if (!pyobj_item) {
    pycall_pyerror_fetch_and_raise("PyList_GetItem in pycall_libpython_api_PyList_GetItem");
  }

  return pycall_pyptr_new(pyobj_item);
}

.PyList_Size(pyptr) ⇒ Object



633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
# File 'ext/pycall/pycall.c', line 633

static VALUE
pycall_libpython_api_PyList_Size(VALUE mod, VALUE pyptr)
{
  PyObject *pyobj;
  Py_ssize_t size;

  if (!is_pycall_pyptr(pyptr)) {
    rb_raise(rb_eTypeError, "PyCall::PyPtr is required");
  }

  pyobj = get_pyobj_ptr(pyptr);
  size = Py_API(PyList_Size)(pyobj);
  if (size < 0) {
    pycall_pyerror_fetch_and_raise("PyList_Size in pycall_libpython_api_PyList_Size");
  }

  return SSIZET2NUM(size);
}

.PyObject_Dir(pyptr) ⇒ Object



614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
# File 'ext/pycall/pycall.c', line 614

static VALUE
pycall_libpython_api_PyObject_Dir(VALUE mod, VALUE pyptr)
{
  PyObject *dir;
  PyObject *pyobj;

  if (!is_pycall_pyptr(pyptr)) {
    rb_raise(rb_eTypeError, "PyCall::PyPtr is required");
  }

  pyobj = get_pyobj_ptr(pyptr);
  dir = Py_API(PyObject_Dir)(pyobj);
  if (pyobj && !dir) {
    pycall_pyerror_fetch_and_raise("PyObject_Dir in pycall_libpython_api_PyObject_Dir");
  }

  return dir ? pycall_pyptr_new(dir) : Qnil;
}