Sha256: 1de8ea3124ce8b1164b33f2526959673c6a8ab1db33838391a9c7035d23b7bf6

Contents?: true

Size: 621 Bytes

Versions: 21

Compression:

Stored size: 621 Bytes

Contents

require 'ffi'

module PyCall
  module LibPython
    class PyObjectStruct < FFI::Struct
    end

    class PyTypeObjectStruct < PyObjectStruct
    end

    class PyObjectStruct < FFI::Struct
      layout ob_refcnt: :ssize_t,
             ob_type:   PyTypeObjectStruct.by_ref

      def self.null
        new(FFI::Pointer::NULL)
      end

      def py_none?
        PyCall.none?(self)
      end

      def kind_of?(klass)
        klass = klass.__pyobj__ if klass.kind_of? PyObjectWrapper
        return super unless klass.kind_of? PyObjectStruct
        PyCall::Types.pyisinstance(self, klass)
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
pycall-0.1.0.alpha.20170711 lib/pycall/libpython/pyobject_struct.rb