module PyCall::PyTypeObjectWrapper
Public Class Methods
extend_object(cls)
click to toggle source
Calls superclass method
PyCall::PyObjectWrapper::extend_object
# File lib/pycall/pytypeobject_wrapper.rb, line 7 def self.extend_object(cls) unless cls.kind_of? Class raise TypeError, "PyTypeObjectWrapper cannot extend non-class objects" end pyptr = cls.instance_variable_get(:@__pyptr__) unless pyptr.kind_of? PyTypePtr raise TypeError, "@__pyptr__ should have PyCall::PyTypePtr object" end super cls.include PyObjectWrapper end
Public Instance Methods
<(other)
click to toggle source
# File lib/pycall/pytypeobject_wrapper.rb, line 52 def <(other) case other when self false when PyTypeObjectWrapper __pyptr__ < other.__pyptr__ when Class false if other.ancestors.include?(self) when Module if ancestors.include?(other) true elsif other.ancestors.include?(self) false end else raise TypeError, "compared with non class/module" end end
===(other)
click to toggle source
Calls superclass method
# File lib/pycall/pytypeobject_wrapper.rb, line 41 def ===(other) case other when PyObjectWrapper __pyptr__ === other.__pyptr__ when PyPtr __pyptr__ === other else super end end
inherited(subclass)
click to toggle source
# File lib/pycall/pytypeobject_wrapper.rb, line 19 def inherited(subclass) subclass.instance_variable_set(:@__pyptr__, __pyptr__) end
new(*args)
click to toggle source
# File lib/pycall/pytypeobject_wrapper.rb, line 23 def new(*args) wrap_pyptr(LibPython::Helpers.call_object(__pyptr__, *args)) end
wrap_pyptr(pyptr)
click to toggle source
# File lib/pycall/pytypeobject_wrapper.rb, line 27 def wrap_pyptr(pyptr) return pyptr if pyptr.kind_of? self pyptr = pyptr.__pyptr__ if pyptr.kind_of? PyObjectWrapper unless pyptr.kind_of? PyPtr raise TypeError, "unexpected argument type #{pyptr.class} (expected PyCall::PyPtr)" end unless pyptr.kind_of? __pyptr__ raise TypeError, "unexpected argument Python type #{pyptr.__ob_type__.__tp_name__} (expected #{__pyptr__.__tp_name__})" end allocate.tap do |obj| obj.instance_variable_set(:@__pyptr__, pyptr) end end
Private Instance Methods
register_python_type_mapping()
click to toggle source
# File lib/pycall/pytypeobject_wrapper.rb, line 73 def register_python_type_mapping PyCall::Conversion.register_python_type_mapping(__pyptr__, self) end