Top Description Fields Constructors Methods
org.python.core

pack-priv Class PyMethodWrapper

extends AbstractPyObject
implements FastCall
Class Inheritance
All Implemented Interfaces
org.python.core.FastCall
Imports
java.lang.invoke.MethodHandles, org.python.core.Exposed.Member, .PyType.Flag

The Python type types.MethodWrapperType (seen also as <class 'method-wrapper'>) represents a special method bound to a particular target "self" object. It is part of the mechanism which allows a special method defined in Java to be called from Python using its name as an attribute.

An example from the wild is to evaluate: (42).__add__, binding the method __add__ to the target 42, to produce a callable equivalent to λ x . 42+x. An instance of this class results from a call to PyWrapperDescr#__get__(Object, PyType).

Field Summary

Modifier and TypeField and Description
pack-priv PyWrapperDescr
descr

Descriptor for the method being bound.

pack-priv final Object
self

The target object of the method call that results when __call__ is invoked on this object.

pack-priv static final PyType

Constructor Summary

AccessConstructor and Description
pack-priv
PyMethodWrapper(PyWrapperDescr
for the special method to bind
descr
,
Object
to which this method call is bound
self
)

Bind a slot wrapper descriptor to its target.

Method Summary

Modifier and TypeMethod and Description
public Object
__call__(Object[] args, String[] names)

protected Object
protected Object
protected int
protected Object
protected Object
protected Object
protected Object
protected Object
protected Object
public Object
call(Object[]
all arguments given, positional then keyword
args
,
String[]
of keyword arguments or null
names
)

Implements org.python.core.FastCall.call.

Invoke the target object with standard arguments (Object[] and String[]), providing all the argument values from the caller and names for those given by keyword.
public PyType
getType()

Overrides org.python.core.AbstractPyObject.getType.

Implements org.python.core.CraftedPyObject.getType.

The Python type of this object.
public TypeError
typeError(ArgumentError
previously thrown by this object
ae
,
Object[]
all arguments given, positional then keyword
args
,
String[]
of keyword arguments or null
names
)

Implements org.python.core.FastCall.typeError.

Translate an ArgumentError that resulted from a call to this FastCall object, and the arguments that were supplied in the call, to a Python TypeError.
Inherited from org.python.core.AbstractPyObject:
toString

Field Detail

descrback to summary
pack-priv PyWrapperDescr descr

Descriptor for the method being bound.

Annotations
@Member
selfback to summary
pack-priv final Object self

The target object of the method call that results when __call__ is invoked on this object. This is exposed to Python as __self__.

Annotations
@Member:__self__
TYPEback to summary
pack-priv static final PyType TYPE

Constructor Detail

PyMethodWrapperback to summary
pack-priv PyMethodWrapper(PyWrapperDescr descr, Object self)

Bind a slot wrapper descriptor to its target. The result is a callable object e.g. in bark = "Woof!".__mul__, bark will be an instance of this class, "Woof!" is self and str.__mul__ is the descriptor.

Parameters
descr:PyWrapperDescr

for the special method to bind

self:Object

to which this method call is bound

Method Detail

__call__back to summary
public Object __call__(Object[] args, String[] names) throws Throwable
__doc__back to summary
protected Object __doc__()
__eq__back to summary
protected Object __eq__(Object b)
__hash__back to summary
protected int __hash__()
__name__back to summary
protected Object __name__()
__ne__back to summary
protected Object __ne__(Object b)
__objclass__back to summary
protected Object __objclass__()
__qualname__back to summary
protected Object __qualname__() throws AttributeError, Throwable
__repr__back to summary
protected Object __repr__()
__text_signature__back to summary
protected Object __text_signature__()
callback to summary
public Object call(Object[] args, String[] names) throws Throwable

Implements org.python.core.FastCall.call.

Doc from org.python.core.FastCall.call.

Invoke the target object with standard arguments (Object[] and String[]), providing all the argument values from the caller and names for those given by keyword. If no other methods are implemented, a call to any other interface method will land here with an array of the arguments.This is to provide implementations of __call__ with a default when no more optimal call is possible.

np = args.length - names.length arguments are given by position, and the keyword arguments are {names[i]:args[np+i]}.

Parameters
args:Object[]

all arguments given, positional then keyword

names:String[]

of keyword arguments or null

Returns:Object

result of the invocation

Annotations
@Override
Exceptions
Throwable:
from the implementation
getTypeback to summary
public PyType getType()

Overrides org.python.core.AbstractPyObject.getType.

Implements org.python.core.CraftedPyObject.getType.

Doc from org.python.core.CraftedPyObject.getType.

The Python type of this object.

Returns:PyType

type of this object

Annotations
@Override
typeErrorback to summary
public TypeError typeError(ArgumentError ae, Object[] args, String[] names)

Implements org.python.core.FastCall.typeError.

Doc from org.python.core.FastCall.typeError.

Translate an ArgumentError that resulted from a call to this FastCall object, and the arguments that were supplied in the call, to a Python TypeError.

Any of the optimised call(...), or vectorcall(...) methods in this interface may throw ArgumentError as a shorthand. (This is to keep code short, especially when it is a handle graph.) The caller should catch this close to the call and use this method to swap the ArgumentError for a Python TypeError.

Parameters
ae:ArgumentError

previously thrown by this object

args:Object[]

all arguments given, positional then keyword

names:String[]

of keyword arguments or null

Returns:TypeError

Python TypeError to throw

Annotations
@Override