Module: PyCall::LibPython

Defined in:
lib/pycall/init.rb,
lib/pycall/libpython.rb,
lib/pycall/libpython/finder.rb,
lib/pycall/libpython/pyobject_struct.rb,
lib/pycall/libpython/pytypeobject_struct.rb,
ext/pycall/pycall.c

Defined Under Namespace

Modules: API, Finder, Helpers Classes: PyGetSetDef, PyMemberDef, PyMethodDef, PyObjectStruct, PyTypeObjectStruct

Constant Summary collapse

T_SHORT =

types:

0
T_INT =
1
T_LONG =
2
T_FLOAT =
3
T_DOUBLE =
4
T_STRING =
5
T_OBJECT =
6
T_CHAR =
7
T_BYTE =
8
T_UBYTE =
9
T_USHORT =
10
T_UINT =
11
T_ULONG =
12
T_STRING_INPLACE =
13
T_BOOL =
14
T_OBJECT_EX =
16
T_LONGLONG =

added in Python 2.5

17
T_ULONGLONG =

added in Python 2.5

18
T_PYSSIZET =

added in Python 2.6

19
T_NONE =

added in Python 3.0

20
READONLY =

flags:

1
READ_RESTRICTED =
2
PY_WRITE_RESTRICTED =
4
RESTRICTED =
(READ_RESTRICTED | PY_WRITE_RESTRICTED)
Py_TPFLAGS_HAVE_GETCHARBUFFER =

Python 2.7

0x00000001<<0
Py_TPFLAGS_HAVE_SEQUENCE_IN =
0x00000001<<1
Py_TPFLAGS_GC =

was sometimes (0x00000001<<2) in Python <= 2.1

0
Py_TPFLAGS_HAVE_INPLACEOPS =
0x00000001<<3
Py_TPFLAGS_CHECKTYPES =
0x00000001<<4
Py_TPFLAGS_HAVE_RICHCOMPARE =
0x00000001<<5
Py_TPFLAGS_HAVE_WEAKREFS =
0x00000001<<6
Py_TPFLAGS_HAVE_ITER =
0x00000001<<7
Py_TPFLAGS_HAVE_CLASS =
0x00000001<<8
Py_TPFLAGS_HAVE_INDEX =
0x00000001<<17
Py_TPFLAGS_HAVE_NEWBUFFER =
0x00000001<<21
Py_TPFLAGS_STRING_SUBCLASS =
0x00000001<<27
Py_TPFLAGS_HEAPTYPE =

Python 3.0+ has only these:

0x00000001<<9
Py_TPFLAGS_BASETYPE =
0x00000001<<10
Py_TPFLAGS_READY =
0x00000001<<12
Py_TPFLAGS_READYING =
0x00000001<<13
Py_TPFLAGS_HAVE_GC =
0x00000001<<14
Py_TPFLAGS_HAVE_VERSION_TAG =
0x00000001<<18
Py_TPFLAGS_VALID_VERSION_TAG =
0x00000001<<19
Py_TPFLAGS_IS_ABSTRACT =
0x00000001<<20
Py_TPFLAGS_INT_SUBCLASS =
0x00000001<<23
Py_TPFLAGS_LONG_SUBCLASS =
0x00000001<<24
Py_TPFLAGS_LIST_SUBCLASS =
0x00000001<<25
Py_TPFLAGS_TUPLE_SUBCLASS =
0x00000001<<26
Py_TPFLAGS_BYTES_SUBCLASS =
0x00000001<<27
Py_TPFLAGS_UNICODE_SUBCLASS =
0x00000001<<28
Py_TPFLAGS_DICT_SUBCLASS =
0x00000001<<29
Py_TPFLAGS_BASE_EXC_SUBCLASS =
0x00000001<<30
Py_TPFLAGS_TYPE_SUBCLASS =
0x00000001<<31
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION_ =

only use this if we have the stackless extension

0x00000003<<15
METH_VARARGS =

ml_flags should be one of:

0x0001
METH_KEYWORDS =

args are a tuple of arguments

0x0002
METH_NOARGS =

two arguments: the varargs and the kwargs

0x0004
METH_O =

no arguments (NULL argument pointer)

0x0008
METH_CLASS =

not sure when these are needed:

0x0010
METH_STATIC =

for class methods

0x0020
PYTHON_DESCRIPTION =
python_description
PYTHON_VERSION =
python_version_string

Class Method Summary collapse

Class Method Details

.const_missing(name) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/pycall/init.rb', line 13

def self.const_missing(name)
  case name
  when :API, :Conversion, :Helpers, :PYTHON_DESCRIPTION, :PYTHON_VERSION
    PyCall.init
    const_get(name)
  else
    super
  end
end

.handleObject



5
6
7
8
9
10
# File 'lib/pycall/libpython.rb', line 5

def self.handle
  # NOTE: PyCall.init redefine this method.
  #       See pycall/init.rb for the detail.
  PyCall.init
  handle
end