@Override public PyObject __call__(PyObject args[], String keywords[]) { if (model instanceof TemplateMethodModel) { boolean isEx = model instanceof TemplateMethodModelEx; List list = new ArrayList(args.length); try { for (int i = 0; i < args.length; ++i) { list.add( isEx ? (Object) wrap(args[i]) : (Object) ( args[i] == null ? null : args[i].toString())); } return unwrap((TemplateModel) ((TemplateMethodModelEx) model).exec(list)); } catch (TemplateModelException e) { throw Py.JavaError(e); } } throw Py.TypeError("call of non-method model (" + getModelClass() + ")"); }
@Override public PyObject __finditem__(String key) { if (model instanceof TemplateHashModel) { try { return unwrap(((TemplateHashModel) model).get(key)); } catch (TemplateModelException e) { throw Py.JavaError(e); } } throw Py.TypeError("item lookup on non-hash model (" + getModelClass() + ")"); }
@Override public PyObject __finditem__(int index) { if (model instanceof TemplateSequenceModel) { try { return unwrap(((TemplateSequenceModel) model).get(index)); } catch (TemplateModelException e) { throw Py.JavaError(e); } } throw Py.TypeError("item lookup on non-sequence model (" + getModelClass() + ")"); }
public void setDict(PyObject newDict) { if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) { dict=newDict; if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&!JyAttribute.hasAttr(this,JyAttribute.FINALIZE_TRIGGER_ATTR)) { FinalizeTrigger.ensureFinalizer(this); } } else { throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName()); } }
public void setDict(PyObject newDict) { if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) { dict=newDict; if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&!JyAttribute.hasAttr(this,JyAttribute.FINALIZE_TRIGGER_ATTR)) { FinalizeTrigger.ensureFinalizer(this); } } else { throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName()); } }
public void setDict(PyObject newDict) { if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) { dict=newDict; if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&!JyAttribute.hasAttr(this,JyAttribute.FINALIZE_TRIGGER_ATTR)) { FinalizeTrigger.ensureFinalizer(this); } } else { throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName()); } }
public void setDict(PyObject newDict) { if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) { dict=newDict; if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&!JyAttribute.hasAttr(this,JyAttribute.FINALIZE_TRIGGER_ATTR)) { FinalizeTrigger.ensureFinalizer(this); } } else { throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName()); } }
public PyObject __int__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__int__"); if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) return res; throw Py.TypeError("__int__"+" should return an integer"); } return super.__int__(); }
public PyObject __index__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__index__"); if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyInteger||res instanceof PyLong) { return res; } throw Py.TypeError(String.format("__index__ returned non-(int,long) (type %s)",res.getType().fastGetName())); } return super.__index__(); }
public PyFloat __float__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__float__"); if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyFloat) return(PyFloat)res; throw Py.TypeError("__float__"+" returned non-"+"float"+" (type "+res.getType().fastGetName()+")"); } return super.__float__(); }
public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyComplex) return(PyComplex)res; throw Py.TypeError("__complex__"+" returned non-"+"complex"+" (type "+res.getType().fastGetName()+")"); } return super.__complex__(); }
public PyString __repr__() { 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) return(PyString)res; throw Py.TypeError("__repr__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); } return super.__repr__(); }
public PyFloat __float__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__float__"); if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyFloat) return(PyFloat)res; throw Py.TypeError("__float__"+" returned non-"+"float"+" (type "+res.getType().fastGetName()+")"); } return super.__float__(); }
public PyComplex __complex__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__complex__"); if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyComplex) return(PyComplex)res; throw Py.TypeError("__complex__"+" returned non-"+"complex"+" (type "+res.getType().fastGetName()+")"); } return super.__complex__(); }
public PyString __oct__() { PyType self_type=getType(); PyObject impl=self_type.lookup("__oct__"); if (impl!=null) { PyObject res=impl.__get__(this,self_type).__call__(); if (res instanceof PyString) return(PyString)res; throw Py.TypeError("__oct__"+" returned non-"+"string"+" (type "+res.getType().fastGetName()+")"); } return super.__oct__(); }
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(); }
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(); }
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(); }
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(); }
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(); }