001: // Copyright (c) Corporation for National Research Initiatives
002: package org.python.core;
003:
004: import java.io.Serializable;
005:
006: /**
007: * A class representing the singleton None object,
008: */
009: public class PyNone extends PyObject implements Serializable {
010:
011: //~ BEGIN GENERATED REGION -- DO NOT EDIT SEE gexpose.py
012: /* type info */
013:
014: public static final String exposed_name = "NoneType";
015:
016: public static void typeSetup(PyObject dict, PyType.Newstyle marker) {
017: class exposed___repr__ extends PyBuiltinMethodNarrow {
018:
019: exposed___repr__(PyObject self, PyBuiltinFunction.Info info) {
020: super (self, info);
021: }
022:
023: public PyBuiltinFunction bind(PyObject self) {
024: return new exposed___repr__(self, info);
025: }
026:
027: public PyObject __call__() {
028: return new PyString(((PyNone) self).NoneType_toString());
029: }
030:
031: }
032: dict.__setitem__("__repr__", new PyMethodDescr("__repr__",
033: PyNone.class, 0, 0, new exposed___repr__(null, null)));
034: class exposed___nonzero__ extends PyBuiltinMethodNarrow {
035:
036: exposed___nonzero__(PyObject self,
037: PyBuiltinFunction.Info info) {
038: super (self, info);
039: }
040:
041: public PyBuiltinFunction bind(PyObject self) {
042: return new exposed___nonzero__(self, info);
043: }
044:
045: public PyObject __call__() {
046: return Py.newBoolean(((PyNone) self)
047: .NoneType___nonzero__());
048: }
049:
050: }
051: dict.__setitem__("__nonzero__", new PyMethodDescr(
052: "__nonzero__", PyNone.class, 0, 0,
053: new exposed___nonzero__(null, null)));
054: }
055:
056: //~ END GENERATED REGION -- DO NOT EDIT SEE gexpose.py
057:
058: private static final PyType NONETYPE = PyType
059: .fromClass(PyNone.class);
060:
061: PyNone() {
062: super (NONETYPE);
063: }
064:
065: private Object writeReplace() {
066: return new Py.SingletonResolver("None");
067: }
068:
069: public boolean __nonzero__() {
070: return NoneType___nonzero__();
071: }
072:
073: final boolean NoneType___nonzero__() {
074: return false;
075: }
076:
077: public Object __tojava__(Class c) {
078: //Danger here. java.lang.Object gets null not None
079: if (c == PyObject.class)
080: return this ;
081: if (c.isPrimitive())
082: return Py.NoConversion;
083: return null;
084: }
085:
086: public String toString() throws PyIgnoreMethodTag {
087: return NoneType_toString();
088: }
089:
090: final String NoneType_toString() {
091: return "None";
092: }
093:
094: public boolean isMappingType() {
095: return false;
096: }
097:
098: public boolean isSequenceType() {
099: return false;
100: }
101:
102: public boolean isNumberType() {
103: return false;
104: }
105:
106: public String asStringOrNull(int index) {
107: return null;
108: }
109: }
|