1 package org.python.core; 2 3 public class PyClassMethod extends PyObject implements PyType.Newstyle { 4 5 6 public final static String exposed_name = "classmethod"; 7 8 public static void typeSetup(PyObject dict, PyType.Newstyle marker) { 9 12 dict 13 .__setitem__( 14 "__new__", 15 new PyNewWrapper(PyClassMethod.class, "__new__", 1, 1) { 16 public PyObject new_impl( 17 boolean init, 18 PyType subtype, 19 PyObject[] args, 20 String [] keywords) { 21 if (keywords.length != 0 || args.length!=1) { 22 throw info.unexpectedCall(args.length,keywords.length!=0); 23 } 24 return new PyClassMethod(args[0]); 25 } }); 27 } 28 29 protected PyObject callable; 30 31 public PyClassMethod(PyObject callable) { 32 this.callable = callable; 33 } 34 35 public PyObject __get__(PyObject obj, PyObject type) { 36 if (type == null) 37 type = obj.getType(); 38 return new PyMethod(type, callable, type.getType()); 39 } 40 41 } 42 | Popular Tags |