Sha256: 7a8a596725f1723ac46c47675a4e8fc1c5168911a150d6d0211177b5d09496d9

Contents?: true

Size: 621 Bytes

Versions: 1

Compression:

Stored size: 621 Bytes

Contents

module PyBind
  module TypeCast
    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

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

  class PyObjectStruct
    def to_ruby
      TypeCast.from_python(self)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pybind-0.1.0 lib/pybind/typecast.rb