01: package org.python.core;
02:
03: public class PyClassMethodDescr extends PyMethodDescr {
04:
05: public PyClassMethodDescr(String name, Class c, int minargs,
06: int maxargs, PyBuiltinFunction meth) {
07: super (name, c, minargs, maxargs, meth);
08: }
09:
10: protected void checkCallerType(PyObject obj) {
11: if ((PyType) obj != dtype && !((PyType) obj).isSubType(dtype))
12: throw get_wrongtype((PyType) obj);
13: }
14:
15: public PyObject __get__(PyObject obj, PyObject type) {
16: if (obj != null) {
17: checkCallerType(obj.getType());
18: return meth.bind(obj.getType());
19: } else if (type != null) {
20: checkCallerType(type);
21: return meth.bind(type);
22: }
23: return this;
24: }
25: }
|