All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.python.core.PyClassMethodDescr Maven / Gradle / Ivy

Go to download

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

There is a newer version: 2.7.4
Show newest version
package org.python.core;

public class PyClassMethodDescr extends PyMethodDescr {

    public PyClassMethodDescr(String name,
                              Class c,
                              int minargs,
                              int maxargs,
                              PyBuiltinFunction meth) {
        super(name, c, minargs, maxargs, meth);
    }

    protected void checkCallerType(PyObject obj) {
        if((PyType)obj != dtype && !((PyType)obj).isSubType(dtype))
            throw get_wrongtype((PyType)obj);
    }

    public PyObject __get__(PyObject obj, PyObject type) {
        if (obj != null) {
            checkCallerType(obj.getType());
            return meth.bind(obj.getType()); 
        }else if(type != null){
            checkCallerType(type);
            return meth.bind(type);
        }
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy