/** * convert a PyObject into a long between Long.MIN_VALUE and Long.MAX_VALUE */ private static long getLong(PyObject pyo) { if (pyo instanceof PyLong) { return getLong(((PyLong)pyo)); } return pyo.asLong(); }
@Override public long asLong(int index) throws ConversionException { return getValue().asLong(index); }
@ExposedMethod final void Random_jumpahead(PyObject arg0) { if (!(arg0 instanceof PyInteger || arg0 instanceof PyLong)) { throw Py.TypeError(String.format("jumpahead requires an integer, not '%s'", arg0.getType().fastGetName())); } for (long i = arg0.asLong(); i > 0; i--) { this.javaRandom.nextInt(); } }
public static String getPyObjectValueAsString(PyObject obj) { if (obj == null) return ""; PyType type = obj.getType(); if (type.getName().equals("long")) return Long.toString(obj.asLong()); else if (type.getName().equals("int")) return Integer.toString(obj.asInt()); else if (type.getName().equals("bool")) return obj.asInt() != 0 ? "true" : "false"; return obj.asString(); }
@ExposedMethod(defaults = {"null"}, doc = BuiltinDocs.file_truncate_doc) final void file_truncate(PyObject position) { if (position == null) { file_truncate(); return; } file_truncate(position.asLong()); }
public static int unichr(PyObject obj) { long l = obj.asLong(); if (l < PySystemState.minint) { throw Py.OverflowError("signed integer is less than minimum"); } else if (l > PySystemState.maxint) { throw Py.OverflowError("signed integer is greater than maximum"); } return unichr((int)l); }
public static PatternObject compile(PyString pattern, int flags, PyObject code, int groups, PyObject groupindex, PyObject indexgroup) { int[] ccode = new int[code.__len__()]; int i = 0; for (PyObject item : code.asIterable()) { ccode[i++] = (int)item.asLong(); } return new PatternObject(pattern, flags, ccode, groups, groupindex, indexgroup); }
@ExposedMethod(defaults = "null", doc = truncate_doc) final long FileIO_truncate(PyObject size) { return (size != null) ? _truncate(size.asLong()) : _truncate(); }
public long tell() { PyType self_type=getType(); PyObject impl=self_type.lookup("tell"); if (impl!=null) { return impl.__get__(this,self_type).__call__().asLong(); } else { return super.tell(); } }
public long truncate() { PyType self_type=getType(); PyObject impl=self_type.lookup("truncate"); if (impl!=null) { return impl.__get__(this,self_type).__call__().asLong(); } else { return super.truncate(); } }
public long truncate() { PyType self_type=getType(); PyObject impl=self_type.lookup("truncate"); if (impl!=null) { return impl.__get__(this,self_type).__call__().asLong(); } else { return super.truncate(); } }
public long tell() { PyType self_type=getType(); PyObject impl=self_type.lookup("tell"); if (impl!=null) { return impl.__get__(this,self_type).__call__().asLong(); } else { return super.tell(); } }
public long tell() { PyType self_type=getType(); PyObject impl=self_type.lookup("tell"); if (impl!=null) { return impl.__get__(this,self_type).__call__().asLong(); } else { return super.tell(); } }
public long truncate() { PyType self_type=getType(); PyObject impl=self_type.lookup("truncate"); if (impl!=null) { return impl.__get__(this,self_type).__call__().asLong(); } else { return super.truncate(); } }
public long truncate(long size) { PyType self_type=getType(); PyObject impl=self_type.lookup("truncate"); if (impl!=null) { return impl.__get__(this,self_type).__call__(Py.newLong(size)).asLong(); } else { return super.truncate(size); } }
public long truncate(long size) { PyType self_type=getType(); PyObject impl=self_type.lookup("truncate"); if (impl!=null) { return impl.__get__(this,self_type).__call__(Py.newLong(size)).asLong(); } else { return super.truncate(size); } }
public long truncate(long size) { PyType self_type=getType(); PyObject impl=self_type.lookup("truncate"); if (impl!=null) { return impl.__get__(this,self_type).__call__(Py.newLong(size)).asLong(); } else { return super.truncate(size); } }
public long seek(long pos,int whence) { PyType self_type=getType(); PyObject impl=self_type.lookup("seek"); if (impl!=null) { return impl.__get__(this,self_type).__call__(Py.newLong(pos),Py.newInteger(whence)).asLong(); } else { return super.seek(pos,whence); } }
public long seek(long pos,int whence) { PyType self_type=getType(); PyObject impl=self_type.lookup("seek"); if (impl!=null) { return impl.__get__(this,self_type).__call__(Py.newLong(pos),Py.newInteger(whence)).asLong(); } else { return super.seek(pos,whence); } }
public long seek(long pos,int whence) { PyType self_type=getType(); PyObject impl=self_type.lookup("seek"); if (impl!=null) { return impl.__get__(this,self_type).__call__(Py.newLong(pos),Py.newInteger(whence)).asLong(); } else { return super.seek(pos,whence); } }