001: package org.python.core;
002:
003: public class PyProperty extends PyObject implements PyType.Newstyle {
004: //~ BEGIN GENERATED REGION -- DO NOT EDIT SEE gexpose.py
005: /* type info */
006:
007: public static final String exposed_name = "property";
008:
009: public static void typeSetup(PyObject dict, PyType.Newstyle marker) {
010: dict.__setitem__("fget", new PyGetSetDescr("fget",
011: PyProperty.class, "getFget", "setFget", null));
012: dict.__setitem__("fset", new PyGetSetDescr("fset",
013: PyProperty.class, "getFset", "setFset", null));
014: dict.__setitem__("fdel", new PyGetSetDescr("fdel",
015: PyProperty.class, "getFdel", "setFdel", null));
016: dict.__setitem__("__doc__", new PyGetSetDescr("__doc__",
017: PyProperty.class, "getDoc", "setDoc", null));
018: class exposed___get__ extends PyBuiltinMethodNarrow {
019:
020: exposed___get__(PyObject self, PyBuiltinFunction.Info info) {
021: super (self, info);
022: }
023:
024: public PyBuiltinFunction bind(PyObject self) {
025: return new exposed___get__(self, info);
026: }
027:
028: public PyObject __call__(PyObject arg0, PyObject arg1) {
029: PyObject obj = (arg0 == Py.None) ? null : arg0;
030: PyObject type = (arg1 == null) ? obj : arg1;
031: return ((PyProperty) self).property___get__(obj, type);
032: }
033:
034: public PyObject __call__(PyObject arg0) {
035: PyObject obj = (arg0 == Py.None) ? null : arg0;
036: PyObject type = ((null) == null) ? obj : (null);
037: return ((PyProperty) self).property___get__(obj, type);
038: }
039:
040: }
041: dict.__setitem__("__get__",
042: new PyMethodDescr("__get__", PyProperty.class, 1, 2,
043: new exposed___get__(null, null)));
044: class exposed___set__ extends PyBuiltinMethodNarrow {
045:
046: exposed___set__(PyObject self, PyBuiltinFunction.Info info) {
047: super (self, info);
048: }
049:
050: public PyBuiltinFunction bind(PyObject self) {
051: return new exposed___set__(self, info);
052: }
053:
054: public PyObject __call__(PyObject arg0, PyObject arg1) {
055: ((PyProperty) self).property___set__(arg0, arg1);
056: return Py.None;
057: }
058:
059: }
060: dict.__setitem__("__set__",
061: new PyMethodDescr("__set__", PyProperty.class, 2, 2,
062: new exposed___set__(null, null)));
063: class exposed___delete__ extends PyBuiltinMethodNarrow {
064:
065: exposed___delete__(PyObject self,
066: PyBuiltinFunction.Info info) {
067: super (self, info);
068: }
069:
070: public PyBuiltinFunction bind(PyObject self) {
071: return new exposed___delete__(self, info);
072: }
073:
074: public PyObject __call__(PyObject arg0) {
075: ((PyProperty) self).property___delete__(arg0);
076: return Py.None;
077: }
078:
079: }
080: dict.__setitem__("__delete__", new PyMethodDescr("__delete__",
081: PyProperty.class, 1, 1, new exposed___delete__(null,
082: null)));
083: class exposed___init__ extends PyBuiltinMethod {
084:
085: exposed___init__(PyObject self, PyBuiltinFunction.Info info) {
086: super (self, info);
087: }
088:
089: public PyBuiltinFunction bind(PyObject self) {
090: return new exposed___init__(self, info);
091: }
092:
093: public PyObject __call__(PyObject[] args) {
094: return __call__(args, Py.NoKeywords);
095: }
096:
097: public PyObject __call__(PyObject[] args, String[] keywords) {
098: ((PyProperty) self).property_init(args, keywords);
099: return Py.None;
100: }
101:
102: }
103: dict.__setitem__("__init__", new PyMethodDescr("__init__",
104: PyProperty.class, -1, -1, new exposed___init__(null,
105: null)));
106: dict.__setitem__("__new__", new PyNewWrapper(PyProperty.class,
107: "__new__", -1, -1) {
108:
109: public PyObject new_impl(boolean init, PyType subtype,
110: PyObject[] args, String[] keywords) {
111: PyProperty newobj;
112: if (for_type == subtype) {
113: newobj = new PyProperty();
114: if (init)
115: newobj.property_init(args, keywords);
116: } else {
117: newobj = new PyPropertyDerived(subtype);
118: }
119: return newobj;
120: }
121:
122: });
123: }
124:
125: //~ END GENERATED REGION -- DO NOT EDIT SEE gexpose.py
126:
127: private static final PyType PROPERTYTYPE = PyType
128: .fromClass(PyProperty.class);
129:
130: protected PyObject fget;
131: protected PyObject fset;
132: protected PyObject fdel;
133: protected PyObject doc;
134:
135: public PyProperty() {
136: this (PROPERTYTYPE);
137: }
138:
139: public PyProperty(PyType subType) {
140: super (subType);
141: }
142:
143: public PyObject getDoc() {
144: return doc;
145: }
146:
147: public PyObject getFdel() {
148: return fdel;
149: }
150:
151: public PyObject getFset() {
152: return fset;
153: }
154:
155: public PyObject getFget() {
156: return fget;
157: }
158:
159: // These methods are to conform to test_descr.py
160: // However I believe that this should be fixed through
161: // PyGetSetDescr.java instead
162: // Carlos Quiroz: 19.11.2005
163: public void setFget(PyObject py) {
164: throw Py.TypeError("readonly attribute");
165: }
166:
167: public void setFset(PyObject py) {
168: throw Py.TypeError("readonly attribute");
169: }
170:
171: public void setFdel(PyObject py) {
172: throw Py.TypeError("readonly attribute");
173: }
174:
175: public void setDoc(PyObject py) {
176: throw Py.TypeError("readonly attribute");
177: }
178:
179: public void property_init(PyObject[] args, String[] keywords) {
180: ArgParser argparse = new ArgParser("property", args, keywords,
181: new String[] { "fget", "fset", "fdel", "doc" }, 0);
182: fget = argparse.getPyObject(0, null);
183: fget = fget == Py.None ? null : fget;
184: fset = argparse.getPyObject(1, null);
185: fset = fset == Py.None ? null : fset;
186: fdel = argparse.getPyObject(2, null);
187: fdel = fdel == Py.None ? null : fdel;
188: doc = argparse.getPyObject(3, null);
189: }
190:
191: public PyObject __call__(PyObject arg1, PyObject args[],
192: String keywords[]) {
193: return fget.__call__(arg1);
194: }
195:
196: public PyObject __get__(PyObject obj, PyObject type) {
197: return property___get__(obj, type);
198: }
199:
200: final PyObject property___get__(PyObject obj, PyObject type) {
201: if (obj == null || null == Py.None)
202: return this ;
203: if (fget == null)
204: throw Py.AttributeError("unreadable attribute");
205: return fget.__call__(obj);
206: }
207:
208: public void __set__(PyObject obj, PyObject value) {
209: property___set__(obj, value);
210: }
211:
212: final void property___set__(PyObject obj, PyObject value) {
213: if (fset == null)
214: throw Py.AttributeError("can't set attribute");
215: fset.__call__(obj, value);
216: }
217:
218: public void __delete__(PyObject obj) {
219: property___delete__(obj);
220: }
221:
222: final void property___delete__(PyObject obj) {
223: if (fdel == null)
224: throw Py.AttributeError("can't delete attribute");
225: fdel.__call__(obj);
226: }
227:
228: }
|