Module: PyBind::TypeCast

Defined in:
lib/pybind/typecast.rb

Class Method Summary collapse

Class Method Details

.from_python(pyobj) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/pybind/typecast.rb', line 3

def self.from_python(pyobj)
  pystruct = pyobj.to_python_struct
  return nil if pystruct.null? || pystruct.none?

  Types.pytypes.each do |pytype|
    return pytype.from_python(pystruct) if pytype.python_instance?(pystruct)
  end
  PyObject.from_python(pystruct)
end

.to_python_arguments(indices) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/pybind/typecast.rb', line 13

def self.to_python_arguments(indices)
  if indices.length == 1
    indices = indices[0]
  else
    indices = PyTuple.new(indices)
  end
  indices.to_python
end