Module: PyCall::LibPython::API

Defined in:
ext/pycall/pycall.c

Class Method Summary collapse

Class Method Details

.builtins_module_ptrObject

PyCall::LibPython::API ====



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

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



585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
# File 'ext/pycall/pycall.c', line 585

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



566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
# File 'ext/pycall/pycall.c', line 566

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



547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
# File 'ext/pycall/pycall.c', line 547

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