Differences between revisions 1 and 2
Revision 1 as of 2005-02-11 02:21:43
Size: 1187
Comment:
Revision 2 as of 2005-02-11 02:24:11
Size: 1285
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Define fields needed by Jython:
* __class__
* __methods__
* __members__

== Example Code ==

Define fields needed by Jython: * class * methods * members

Example Code

public class JythonClass extends PyObject implements ClassDictInit {

  /** Field __class__ */
  public static PyClass __class__;

  /** Field __methods__ */
  protected static PyList __methods__;

  /** Field __members__ */
  protected static PyList __members__;

  /** Field exposedtojython */
  protected long exposedtojython

  /** Field hiddenFromJython */
  protected long hiddenFromJython

  static {
    PyObject[] m = new PyObject[1];

    m[0] = Py.newString("amethod");

    __methods__ = new PyList(m);
    m = new PyObject[1];
    m[0] = Py.newString("amember");

    __members__ = new PyList(m);
  }

  /**
   * Initializes the object's namespace.
   *
   * @param dict
   */
  static public void classDictInit(PyObject dict) {

    dict.__setitem__("ticks", new DateTimeFunc("ticks", 1, 1, 2, true, "ticks"));
    dict.__setitem__("gmtoffset", new DateTimeFunc("gmtoffset", 2, 0, 0, true, "gmtoffset"));

    // hide from python
    dict.__setitem__("classDictInit", null);
    dict.__setitem__("getPyClass", null);
    dict.__setitem__("hideFromJython", null);
    dict.__setitem__("otherHiddenMethod", null);
  }

JythonClassesInJava (last edited 2008-11-15 09:16:02 by localhost)