<commit_before>require 'rubypython/rubypyapi/python'
require 'rubypython/rubypyapi/macros'
require 'rubypython/rubypyapi/ptor'
require 'rubypython/rubypyapi/rtop'
require 'ffi'

module RubyPyApi

  #This object is an opaque wrapper around the C PyObject* type used by the python
  #C API. This class <em>should not</em> be used by the end user. They should instead
  #make use of the RubyPyApi::RubyPyProxy class and its subclasses.
  class PyObject
    attr_accessor :pObject

    def initialize(rObject, has_pobject=true)
      if has_pobject
        @pObject = RTOP.rtopObject rObject
      end
    end

    def rubify
      PTOR.ptorObject @pObject
    end

    def hasAttr(attrName)
      Python.PyObject_HasAttrString(@pObject, attrName) == 1
    end

    def getAttr(attrName)
      pyAttr = Python.PyObject_GetAttrString @pObject, attrName
      rbAttr = self.class.new nil, false
      rbAttr.pObject = pyAttr
      rbAttr
    end

    def setAttr(attrName, rbPyAttr)
      Python.PyObject_SetAttrString(@pObject, attrName, rbPyAttr.pObject) != -1
    end

    def callObject(rbPyArgs)
      pyReturn = Python.PyObject_CallObject(@pObject, rbPyArgs.pObject)
      rbReturn = self.class.new nil, false
      rbReturn.pObject = pyReturn
      rbReturn
    end

    def xDecref
      Macros.rpPy_mXDECREF @pObject
    end

    def xIncref
      Macros.rpPy_mXINCREF @pObject
    end

    def null?
      @pObject.address == 0
    end

    def cmp(other)
      Python.PyObject_Compare @pObject, other.pObject 
    end

    def functionOrMethod?
      isFunc = (Macros.rpPyObject_mTypeCheck(@pObject, Python.PyFunction_Type.to_ptr) != 0)
      isMethod = (Macros.rpPyObject_mTypeCheck(@pObject, Python.PyMethod_Type.to_ptr) != 0)
      isFunc or isMethod
    end

    def callable?
      Python.PyCallable_Check @pObject
    end

    def self.makeTuple(rbObject)<commit_msg>Fixed a bug in the PyObject.callable? method that caused it to be inaccurate.<commit_after>require 'rubypython/rubypyapi/python'
require 'rubypython/rubypyapi/macros'
require 'rubypython/rubypyapi/ptor'
require 'rubypython/rubypyapi/rtop'
require 'ffi'

module RubyPyApi

  #This object is an opaque wrapper around the C PyObject* type used by the python
  #C API. This class <em>should not</em> be used by the end user. They should instead
  #make use of the RubyPyApi::RubyPyProxy class and its subclasses.
  class PyObject
    attr_accessor :pObject

    def initialize(rObject, has_pobject=true)
      if has_pobject
        @pObject = RTOP.rtopObject rObject
      end
    end

    def rubify
      PTOR.ptorObject @pObject
    end

    def hasAttr(attrName)
      Python.PyObject_HasAttrString(@pObject, attrName) == 1
    end

    def getAttr(attrName)
      pyAttr = Python.PyObject_GetAttrString @pObject, attrName
      rbAttr = self.class.new nil, false
      rbAttr.pObject = pyAttr
      rbAttr
    end

    def setAttr(attrName, rbPyAttr)
      Python.PyObject_SetAttrString(@pObject, attrName, rbPyAttr.pObject) != -1
    end

    def callObject(rbPyArgs)
      pyReturn = Python.PyObject_CallObject(@pObject, rbPyArgs.pObject)
      rbReturn = self.class.new nil, false
      rbReturn.pObject = pyReturn
      rbReturn
    end

    def xDecref
      Macros.rpPy_mXDECREF @pObject
    end

    def xIncref
      Macros.rpPy_mXINCREF @pObject
    end

    def null?
      @pObject.address == 0
    end

    def cmp(other)
      Python.PyObject_Compare @pObject, other.pObject 
    end

    def functionOrMethod?
      isFunc = (Macros.rpPyObject_mTypeCheck(@pObject, Python.PyFunction_Type.to_ptr) != 0)
      isMethod = (Macros.rpPyObject_mTypeCheck(@pObject, Python.PyMethod_Type.to_ptr) != 0)
      isFunc or isMethod
    end

    def callable?
      Python.PyCallable_Check(@pObject) != 0
    end

    def self.makeTuple(rbObject)
{'fraction_non_alphanumeric': 0.07501306847882906, 'fraction_numerical': 0.002875065342394145, 'mean_word_length': 3.0199579831932772, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2476314', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1277, 'n_words': 317}