KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > python > core > PyClassMethod


1 package org.python.core;
2
3 public class PyClassMethod extends PyObject implements PyType.Newstyle {
4
5     /* type info */
6     public final static String JavaDoc exposed_name = "classmethod";
7     
8     public static void typeSetup(PyObject dict, PyType.Newstyle marker) {
9         // xxx __get__
10
// xxx __init__
11

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 JavaDoc[] 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             } // xxx subclassing
26
});
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