Module: PyCall::PyTypeObjectWrapper
Constant Summary
PyCall::PyObjectWrapper::OPERATOR_METHOD_NAMES
Instance Attribute Summary
#__pyptr__
Class Method Summary
collapse
Instance Method Summary
collapse
#[], #[]=, #call, #coerce, #dup, #inspect, #kind_of?, #method_missing, #respond_to_missing?, #to_f, #to_i, #to_s
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class PyCall::PyObjectWrapper
Class Method Details
.extend_object(cls) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
|
# 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
|
Instance Method Details
#inherited(subclass) ⇒ Object
19
20
21
|
# File 'lib/pycall/pytypeobject_wrapper.rb', line 19
def inherited(subclass)
subclass.instance_variable_set(:@__pyptr__, __pyptr__)
end
|
#new(*args) ⇒ Object
23
24
25
|
# File 'lib/pycall/pytypeobject_wrapper.rb', line 23
def new(*args)
wrap_pyptr(LibPython::Helpers.call_object(__pyptr__, *args))
end
|
#wrap_pyptr(pyptr) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# 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
|