01: //copyright 2001 Finn Bock
02: //copyright 2003 Samuele Pedroni
03:
04: package org.python.modules;
05:
06: import org.python.core.*;
07:
08: public class newmodule {
09:
10: public static PyInstance instance(PyClass cls) {
11: return new PyInstance(cls);
12: }
13:
14: public static PyInstance instance(PyClass cls, PyObject dict) {
15: if (dict == Py.None)
16: return new PyInstance(cls);
17: else
18: return new PyInstance(cls, dict);
19: }
20:
21: public static PyMethod instancemethod(PyObject func,
22: PyObject instance, PyClass clss) {
23: return new PyMethod(instance, func, clss);
24: }
25:
26: public static PyFunction function(PyCode code, PyObject globals) {
27: return function(code, globals, null, Py.EmptyObjects, null);
28: }
29:
30: public static PyFunction function(PyCode code, PyObject globals,
31: String name) {
32: return function(code, globals, name, Py.EmptyObjects, null);
33: }
34:
35: public static PyFunction function(PyCode code, PyObject globals,
36: String name, PyObject[] argdefs) {
37: PyFunction f = new PyFunction(globals, argdefs, code, null,
38: null);
39: if (name != null)
40: f.__name__ = name;
41: return f;
42: }
43:
44: public static PyFunction function(PyCode code, PyObject globals,
45: String name, PyObject[] argdefs, PyObject[] closure) {
46: PyFunction f = new PyFunction(globals, argdefs, code, null,
47: closure);
48: if (name != null)
49: f.__name__ = name;
50: return f;
51: }
52:
53: public static PyModule module(String name) {
54: return new PyModule(name, null);
55: }
56:
57: public static PyClass classobj(String name, PyTuple bases,
58: PyObject dict) {
59: return new PyClass(name, bases, dict);
60: }
61: }
|