@Override public Object __tojava__(Class<?> c) { if (c == Boolean.TYPE || c == Boolean.class || c == Object.class ) { return Boolean.valueOf(getBooleanValue()); } if (c == Integer.TYPE || c == Number.class || c == Integer.class) { return Integer.valueOf(getValue()); } if (c == Byte.TYPE || c == Byte.class) { return Byte.valueOf((byte)(getValue())); } if (c == Short.TYPE || c == Short.class) { return Short.valueOf((short)(getValue())); } if (c == Long.TYPE || c == Long.class) { return Long.valueOf(getValue()); } if (c == Float.TYPE || c == Float.class) { return Float.valueOf(getValue()); } if (c == Double.TYPE || c == Double.class) { return Double.valueOf(getValue()); } return super.__tojava__(c); }
@ExposedMethod(doc = BuiltinDocs.bool___abs___doc) final PyObject bool___abs__() { return Py.newInteger(getValue()); } }
@ExposedMethod(doc = BuiltinDocs.bool___pos___doc) final PyObject bool___pos__() { return Py.newInteger(getValue()); }
private void save_bool(PyObject object) { int value = ((PyBoolean)object).getValue(); if(protocol >= 2) { file.write(value != 0 ? NEWTRUE : NEWFALSE); } else { file.write(INT); file.write(value != 0 ? "01" : "00"); file.write("\n"); } }
@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; } }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.bool___xor___doc) final PyObject bool___xor__(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; } }
@ExposedMethod(type = MethodType.BINARY, doc = BuiltinDocs.bool___and___doc) final PyObject bool___and__(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; } }