public static final PyObject newUnsigned64(long value) { return value < 0 ? Py.newLong(BigInteger.valueOf(value & 0x7fffffffffffffffL).add(UINT64_BASE)) : Py.newInteger(value); }
Object unpack(ByteStream buf) { int b = buf.readByte(); if (b > Byte.MAX_VALUE) b -= 0x100; return Py.newInteger(b); } }
@Override public String toString() { return "<" + get_opname().__getitem__(Py.newInteger(b_type)) + "," + b_handler + "," + b_level + ">"; } }
private PyObject getslice_by_index(int index, PyObject def) { if (index < 0 || index >= groups) throw Py.IndexError("no such group"); index *= 2; int start = mark[index]; int end = mark[index+1]; //System.out.println("group:" + index + " " + start + " " + // end + " l:" + string.length()); if (string == null || start < 0) return def; return string.__getslice__(Py.newInteger(start), Py.newInteger(end)); }
@ExposedMethod(doc = BuiltinDocs.slice_indices_doc) final PyObject slice_indices(PyObject len) { int[] indices = indicesEx(len.asIndex(Py.OverflowError)); return new PyTuple(Py.newInteger(indices[0]), Py.newInteger(indices[1]), Py.newInteger(indices[2])); }
Object unpack(ByteStream buf) { int v = (buf.readByte() << 8) | buf.readByte(); if (v > Short.MAX_VALUE) v -= 0x10000; return Py.newInteger(v); } }
@ExposedMethod(doc = BuiltinDocs.bool___abs___doc) final PyObject bool___abs__() { return Py.newInteger(getValue()); } }
@Hide(posixImpl = PosixImpl.JAVA) public static PyObject waitpid(int pid, int options) { int[] status = new int[1]; pid = posix.waitpid(pid, status, options); if (pid < 0) { throw errorFromErrno(); } return new PyTuple(Py.newInteger(pid), Py.newInteger(status[0])); }
Object unpack(ByteStream buf) { int v = (buf.readByte() << 8) | buf.readByte(); return Py.newInteger(v); } }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rdivmod___doc) final PyObject int___rdivmod__(PyObject left) { if (!canCoerce(left)) { return null; } int leftv = coerce(left); int v = getValue(); long xdivy = divide(leftv, v); return new PyTuple(Py.newInteger(xdivy), Py.newInteger(modulo(leftv, v, xdivy))); }
public static PyException IOError(Constant errno, PyObject filename) { int value = errno.intValue(); PyObject args = new PyTuple(Py.newInteger(value), PosixModule.strerror(value), filename); return new PyException(Py.IOError, args); }
@ExposedNew public static PyObject ScalarCData_new(PyNewWrapper new_, boolean init, PyType subtype, PyObject[] args, String[] keywords) { ScalarCData cdata = new ScalarCData(subtype, getScalarType(subtype)); // If an initial value was supplied, use it, else default to zero cdata.setValue(args.length > 0 ? args[0] : Py.newInteger(0)); return cdata; }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___floordiv___doc) final PyObject int___floordiv__(PyObject right) { if (!canCoerce(right)) { return null; } return Py.newInteger(divide(getValue(), coerce(right))); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___rfloordiv___doc) final PyObject int___rfloordiv__(PyObject left) { if (!canCoerce(left)) { return null; } return Py.newInteger(divide(coerce(left), getValue())); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___xor___doc) final PyObject int___xor__(PyObject right) { int rightv; if (right instanceof PyInteger) { rightv = ((PyInteger)right).getValue(); } else if (right instanceof PyLong) { return int___long__().__xor__(right); } else { return null; } return Py.newInteger(getValue() ^ rightv); }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.int___or___doc) final PyObject int___or__(PyObject right) { int rightv; if (right instanceof PyInteger) { rightv = ((PyInteger)right).getValue(); } else if (right instanceof PyLong) { return int___long__().__or__(right); } else { return null; } return Py.newInteger(getValue() | rightv); }
public PyObject readline(int limit) { PyType self_type=getType(); PyObject impl=self_type.lookup("readline"); if (impl!=null) { return impl.__get__(this,self_type).__call__(Py.newInteger(limit)); } else { return super.readline(limit); } }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.bool___or___doc) final PyObject bool___or__(PyObject right) { if (right instanceof PyBoolean) { return Py.newBoolean(getBooleanValue() | ((PyBoolean) right).getBooleanValue()); } else if (right instanceof PyInteger) { return Py.newInteger(getValue() | ((PyInteger)right).getValue()); } else { return null; } }
public static PyObject get_suffixes() { return new PyList(new PyObject[] {new PyTuple(new PyString(".py"), new PyString("r"), Py.newInteger(PY_SOURCE)), new PyTuple(new PyString("$py.class"), new PyString("rb"), Py.newInteger(PY_COMPILED)),}); }
public static void classDictInit(PyObject dict) { dict.__setitem__("__name__", Py.newString("_csv")); dict.__setitem__("__doc__", __doc__); dict.__setitem__("Dialect", PyDialect.TYPE); dict.__setitem__("Error", Error); for (QuoteStyle style : QuoteStyle.values()) { dict.__setitem__(style.name(), Py.newInteger(style.ordinal())); } dict.__setitem__("classDictInit", null); dict.__setitem__("field_limit", null); }