Sha256: 4b51ce295b2a73678f6c7116cded6353401d7edcd2c44f09c63e084a4f5bed7e

Contents?: true

Size: 907 Bytes

Versions: 3

Compression:

Stored size: 907 Bytes

Contents

require 'ffi'
require 'rubypython/python'

module RubyPython
  #Contains Python C API macros reimplmented in Ruby. For internal use only.
  module Macros
    def self.Py_TYPE(pObjPointer)
      pStruct = Python::PyObjectStruct.new pObjPointer
      pStruct[:ob_type]
    end

    def self.PyObject_TypeCheck(pObject, pTypePointer)
      if Py_TYPE(pObject) == pTypePointer
        1
      else
        0
      end
    end

    def self.Py_True
      Python.Py_TrueStruct.to_ptr
    end

    def self.Py_False
      Python.Py_ZeroStruct.to_ptr
    end

    def self.Py_None
      Python.Py_NoneStruct.to_ptr
    end

    def self.Py_RETURN_FALSE
      Python.Py_IncRef(self.Py_False)
      self.Py_False
    end

    def self.Py_RETURN_TRUE
      Python.Py_IncRef(self.Py_True)
      self.Py_True
    end

    def self.Py_RETURN_NONE
      Python.Py_IncRef(self.Py_None)
      self.Py_None
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubypython-0.3.2 lib/rubypython/macros.rb
rubypython-0.3.1 lib/rubypython/macros.rb
rubypython-0.3.0 lib/rubypython/macros.rb