templates.gderived-defs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jython-standalone Show documentation
Show all versions of jython-standalone Show documentation
Jython is an implementation of the high-level, dynamic, object-oriented
language Python written in 100% Pure Java, and seamlessly integrated with
the Java platform. It thus allows you to run Python on any Java platform.
# copyright 2004-2005 Samuele Pedroni
define: (CompilationUnit)derived_class
/* Generated file, do not modify. See jython/src/templates/gderived.py. */
package org.python.core;
import java.io.Serializable;
public class `concat`(`base,Derived) extends `base implements Slotted {
public PyObject getSlot(int index) {
return slots[index];
}
public void setSlot(int index, PyObject value) {
slots[index] = value;
}
private PyObject[] slots;
`decls;
}
define: (ClassBodyDeclarations)pair
`trailer;
`last;
define: (ClassBodyDeclarations)binary
public PyObject `binary(PyObject other) {
PyType self_type = getType();
PyObject impl = self_type.lookup(`strfy`(`binary));
if (impl != null) {
PyObject res = impl.__get__(this,self_type).__call__(other);
if (res == Py.NotImplemented)
return null;
return res;
}
return super.`binary(other);
}
define: (ClassBodyDeclarations)ibinary
public PyObject `binary(PyObject other) {
PyType self_type = getType();
PyObject impl = self_type.lookup(`strfy`(`binary));
if (impl != null) {
PyObject res = impl.__get__(this,self_type).__call__(other);
if (res == Py.NotImplemented)
return null;
return res;
}
return super.`binary(other);
}
define: (ClassBodyDeclarations)unary
public PyObject `unary() {
PyType self_type = getType();
PyObject impl = self_type.lookup(`strfy`(`unary));
if (impl != null)
return impl.__get__(this,self_type).__call__();
return super.`unary();
}
define: (ClassBodyDeclarations)typed_unary
public `rettype `unary() {
PyType self_type = getType();
PyObject impl = self_type.lookup(`strfy`(`unary));
if (impl != null) {
PyObject res = impl.__get__(this,self_type).__call__();
if (res instanceof `rettype)
return (`rettype)res;
throw Py.TypeError(`strfy`(`unary) + " returned non-" + `strfy`(`rettype_name) + " (type "
+ res.getType().fastGetName() + ")");
}
return super.`unary();
}
define: (ClassBodyDeclarations)userdict
private PyObject dict;
public PyObject fastGetDict() {
return dict;
}
public PyObject getDict() {
return dict;
}
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap || newDict instanceof PyDictionary ) {
dict = newDict;
}
else {
throw Py.TypeError("__dict__ must be set to a Dictionary " + newDict.getClass().getName());
}
}
public void delDict() {
// deleting an object's instance dict makes it grow a new one
dict = new PyStringMap();
}
define: (ClassBodyDeclarations)ctr
public `concat`(`base,Derived)(PyType subtype,`extraargs) {
super(subtype,`extra);
slots = new PyObject[subtype.getNumSlots()];
}
define: (ClassBodyDeclarations)ctr_userdict
public `concat`(`base,Derived)(PyType subtype,`extraargs) {
super(subtype,`extra);
slots = new PyObject[subtype.getNumSlots()];
dict = subtype.instDict();
}
define: (ClassBodyDeclarations)toString
public String toString() {
PyType self_type = getType();
PyObject impl = self_type.lookup("__repr__");
if (impl != null) {
PyObject res = impl.__get__(this,self_type).__call__();
if (!(res instanceof PyString))
throw Py.TypeError("__repr__ returned non-string (type "
+ res.getType().fastGetName() + ")");
return ((PyString)res).toString();
}
return super.toString();
}