KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > python > modules > newmodule


1 //copyright 2001 Finn Bock
2
//copyright 2003 Samuele Pedroni
3

4 package org.python.modules;
5
6 import org.python.core.*;
7
8
9 public class newmodule {
10
11
12     public static PyInstance instance(PyClass cls) {
13         return new PyInstance(cls);
14     }
15
16     public static PyInstance instance(PyClass cls, PyObject dict) {
17         if (dict == Py.None)
18             return new PyInstance(cls);
19         else
20             return new PyInstance(cls, dict);
21     }
22
23
24     public static PyMethod instancemethod(PyObject func, PyObject instance,
25                                           PyClass clss)
26     {
27         return new PyMethod(instance, func, clss);
28     }
29
30
31     public static PyFunction function(PyCode code, PyObject globals) {
32         return function(code, globals, null, Py.EmptyObjects, null);
33     }
34
35     public static PyFunction function(PyCode code, PyObject globals,
36                                       String JavaDoc name)
37     {
38         return function(code, globals, name, Py.EmptyObjects, null);
39     }
40
41     public static PyFunction function(PyCode code, PyObject globals,
42                                       String JavaDoc name, PyObject[] argdefs)
43     {
44         PyFunction f = new PyFunction(globals, argdefs, code, null,null);
45         if (name != null)
46             f.__name__ = name;
47         return f;
48     }
49
50
51     public static PyFunction function(PyCode code, PyObject globals,
52                                       String JavaDoc name, PyObject[] argdefs,
53                                       PyObject[] closure)
54     {
55         PyFunction f = new PyFunction(globals, argdefs, code, null, closure);
56         if (name != null)
57             f.__name__ = name;
58         return f;
59     }
60
61
62
63     public static PyModule module(String JavaDoc name) {
64         return new PyModule(name, null);
65     }
66
67
68     public static PyClass classobj(String JavaDoc name, PyTuple bases,
69                                    PyObject dict)
70     {
71         return new PyClass(name, bases, dict);
72     }
73 }
74
Popular Tags