Source Code Cross Referenced for PyLong.java in  » Testing » Marathon » org » python » core » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » Marathon » org.python.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        // Copyright (c) Corporation for National Research Initiatives
0002:        package org.python.core;
0003:
0004:        import java.math.BigInteger;
0005:        import java.io.Serializable;
0006:
0007:        /**
0008:         * A builtin python long. This is implemented as a
0009:         * java.math.BigInteger.
0010:         */
0011:
0012:        public class PyLong extends PyObject {
0013:            public static final BigInteger minLong = BigInteger
0014:                    .valueOf(Long.MIN_VALUE);
0015:            public static final BigInteger maxLong = BigInteger
0016:                    .valueOf(Long.MAX_VALUE);
0017:            public static final BigInteger maxULong = BigInteger.valueOf(1)
0018:                    .shiftLeft(64).subtract(BigInteger.valueOf(1));
0019:
0020:            //~ BEGIN GENERATED REGION -- DO NOT EDIT SEE gexpose.py
0021:            /* type info */
0022:
0023:            public static final String exposed_name = "long";
0024:
0025:            public static void typeSetup(PyObject dict, PyType.Newstyle marker) {
0026:                class exposed___abs__ extends PyBuiltinMethodNarrow {
0027:
0028:                    exposed___abs__(PyObject self, PyBuiltinFunction.Info info) {
0029:                        super (self, info);
0030:                    }
0031:
0032:                    public PyBuiltinFunction bind(PyObject self) {
0033:                        return new exposed___abs__(self, info);
0034:                    }
0035:
0036:                    public PyObject __call__() {
0037:                        return ((PyLong) self).long___abs__();
0038:                    }
0039:
0040:                }
0041:                dict.__setitem__("__abs__", new PyMethodDescr("__abs__",
0042:                        PyLong.class, 0, 0, new exposed___abs__(null, null)));
0043:                class exposed___float__ extends PyBuiltinMethodNarrow {
0044:
0045:                    exposed___float__(PyObject self, PyBuiltinFunction.Info info) {
0046:                        super (self, info);
0047:                    }
0048:
0049:                    public PyBuiltinFunction bind(PyObject self) {
0050:                        return new exposed___float__(self, info);
0051:                    }
0052:
0053:                    public PyObject __call__() {
0054:                        return ((PyLong) self).long___float__();
0055:                    }
0056:
0057:                }
0058:                dict.__setitem__("__float__", new PyMethodDescr("__float__",
0059:                        PyLong.class, 0, 0, new exposed___float__(null, null)));
0060:                class exposed___hex__ extends PyBuiltinMethodNarrow {
0061:
0062:                    exposed___hex__(PyObject self, PyBuiltinFunction.Info info) {
0063:                        super (self, info);
0064:                    }
0065:
0066:                    public PyBuiltinFunction bind(PyObject self) {
0067:                        return new exposed___hex__(self, info);
0068:                    }
0069:
0070:                    public PyObject __call__() {
0071:                        return ((PyLong) self).long___hex__();
0072:                    }
0073:
0074:                }
0075:                dict.__setitem__("__hex__", new PyMethodDescr("__hex__",
0076:                        PyLong.class, 0, 0, new exposed___hex__(null, null)));
0077:                class exposed___int__ extends PyBuiltinMethodNarrow {
0078:
0079:                    exposed___int__(PyObject self, PyBuiltinFunction.Info info) {
0080:                        super (self, info);
0081:                    }
0082:
0083:                    public PyBuiltinFunction bind(PyObject self) {
0084:                        return new exposed___int__(self, info);
0085:                    }
0086:
0087:                    public PyObject __call__() {
0088:                        return ((PyLong) self).long___int__();
0089:                    }
0090:
0091:                }
0092:                dict.__setitem__("__int__", new PyMethodDescr("__int__",
0093:                        PyLong.class, 0, 0, new exposed___int__(null, null)));
0094:                class exposed___invert__ extends PyBuiltinMethodNarrow {
0095:
0096:                    exposed___invert__(PyObject self,
0097:                            PyBuiltinFunction.Info info) {
0098:                        super (self, info);
0099:                    }
0100:
0101:                    public PyBuiltinFunction bind(PyObject self) {
0102:                        return new exposed___invert__(self, info);
0103:                    }
0104:
0105:                    public PyObject __call__() {
0106:                        return ((PyLong) self).long___invert__();
0107:                    }
0108:
0109:                }
0110:                dict
0111:                        .__setitem__("__invert__", new PyMethodDescr(
0112:                                "__invert__", PyLong.class, 0, 0,
0113:                                new exposed___invert__(null, null)));
0114:                class exposed___long__ extends PyBuiltinMethodNarrow {
0115:
0116:                    exposed___long__(PyObject self, PyBuiltinFunction.Info info) {
0117:                        super (self, info);
0118:                    }
0119:
0120:                    public PyBuiltinFunction bind(PyObject self) {
0121:                        return new exposed___long__(self, info);
0122:                    }
0123:
0124:                    public PyObject __call__() {
0125:                        return ((PyLong) self).long___long__();
0126:                    }
0127:
0128:                }
0129:                dict.__setitem__("__long__", new PyMethodDescr("__long__",
0130:                        PyLong.class, 0, 0, new exposed___long__(null, null)));
0131:                class exposed___neg__ extends PyBuiltinMethodNarrow {
0132:
0133:                    exposed___neg__(PyObject self, PyBuiltinFunction.Info info) {
0134:                        super (self, info);
0135:                    }
0136:
0137:                    public PyBuiltinFunction bind(PyObject self) {
0138:                        return new exposed___neg__(self, info);
0139:                    }
0140:
0141:                    public PyObject __call__() {
0142:                        return ((PyLong) self).long___neg__();
0143:                    }
0144:
0145:                }
0146:                dict.__setitem__("__neg__", new PyMethodDescr("__neg__",
0147:                        PyLong.class, 0, 0, new exposed___neg__(null, null)));
0148:                class exposed___oct__ extends PyBuiltinMethodNarrow {
0149:
0150:                    exposed___oct__(PyObject self, PyBuiltinFunction.Info info) {
0151:                        super (self, info);
0152:                    }
0153:
0154:                    public PyBuiltinFunction bind(PyObject self) {
0155:                        return new exposed___oct__(self, info);
0156:                    }
0157:
0158:                    public PyObject __call__() {
0159:                        return ((PyLong) self).long___oct__();
0160:                    }
0161:
0162:                }
0163:                dict.__setitem__("__oct__", new PyMethodDescr("__oct__",
0164:                        PyLong.class, 0, 0, new exposed___oct__(null, null)));
0165:                class exposed___pos__ extends PyBuiltinMethodNarrow {
0166:
0167:                    exposed___pos__(PyObject self, PyBuiltinFunction.Info info) {
0168:                        super (self, info);
0169:                    }
0170:
0171:                    public PyBuiltinFunction bind(PyObject self) {
0172:                        return new exposed___pos__(self, info);
0173:                    }
0174:
0175:                    public PyObject __call__() {
0176:                        return ((PyLong) self).long___pos__();
0177:                    }
0178:
0179:                }
0180:                dict.__setitem__("__pos__", new PyMethodDescr("__pos__",
0181:                        PyLong.class, 0, 0, new exposed___pos__(null, null)));
0182:                class exposed___add__ extends PyBuiltinMethodNarrow {
0183:
0184:                    exposed___add__(PyObject self, PyBuiltinFunction.Info info) {
0185:                        super (self, info);
0186:                    }
0187:
0188:                    public PyBuiltinFunction bind(PyObject self) {
0189:                        return new exposed___add__(self, info);
0190:                    }
0191:
0192:                    public PyObject __call__(PyObject arg0) {
0193:                        PyObject ret = ((PyLong) self).long___add__(arg0);
0194:                        if (ret == null)
0195:                            return Py.NotImplemented;
0196:                        return ret;
0197:                    }
0198:
0199:                }
0200:                dict.__setitem__("__add__", new PyMethodDescr("__add__",
0201:                        PyLong.class, 1, 1, new exposed___add__(null, null)));
0202:                class exposed___and__ extends PyBuiltinMethodNarrow {
0203:
0204:                    exposed___and__(PyObject self, PyBuiltinFunction.Info info) {
0205:                        super (self, info);
0206:                    }
0207:
0208:                    public PyBuiltinFunction bind(PyObject self) {
0209:                        return new exposed___and__(self, info);
0210:                    }
0211:
0212:                    public PyObject __call__(PyObject arg0) {
0213:                        PyObject ret = ((PyLong) self).long___and__(arg0);
0214:                        if (ret == null)
0215:                            return Py.NotImplemented;
0216:                        return ret;
0217:                    }
0218:
0219:                }
0220:                dict.__setitem__("__and__", new PyMethodDescr("__and__",
0221:                        PyLong.class, 1, 1, new exposed___and__(null, null)));
0222:                class exposed___div__ extends PyBuiltinMethodNarrow {
0223:
0224:                    exposed___div__(PyObject self, PyBuiltinFunction.Info info) {
0225:                        super (self, info);
0226:                    }
0227:
0228:                    public PyBuiltinFunction bind(PyObject self) {
0229:                        return new exposed___div__(self, info);
0230:                    }
0231:
0232:                    public PyObject __call__(PyObject arg0) {
0233:                        PyObject ret = ((PyLong) self).long___div__(arg0);
0234:                        if (ret == null)
0235:                            return Py.NotImplemented;
0236:                        return ret;
0237:                    }
0238:
0239:                }
0240:                dict.__setitem__("__div__", new PyMethodDescr("__div__",
0241:                        PyLong.class, 1, 1, new exposed___div__(null, null)));
0242:                class exposed___divmod__ extends PyBuiltinMethodNarrow {
0243:
0244:                    exposed___divmod__(PyObject self,
0245:                            PyBuiltinFunction.Info info) {
0246:                        super (self, info);
0247:                    }
0248:
0249:                    public PyBuiltinFunction bind(PyObject self) {
0250:                        return new exposed___divmod__(self, info);
0251:                    }
0252:
0253:                    public PyObject __call__(PyObject arg0) {
0254:                        PyObject ret = ((PyLong) self).long___divmod__(arg0);
0255:                        if (ret == null)
0256:                            return Py.NotImplemented;
0257:                        return ret;
0258:                    }
0259:
0260:                }
0261:                dict
0262:                        .__setitem__("__divmod__", new PyMethodDescr(
0263:                                "__divmod__", PyLong.class, 1, 1,
0264:                                new exposed___divmod__(null, null)));
0265:                class exposed___floordiv__ extends PyBuiltinMethodNarrow {
0266:
0267:                    exposed___floordiv__(PyObject self,
0268:                            PyBuiltinFunction.Info info) {
0269:                        super (self, info);
0270:                    }
0271:
0272:                    public PyBuiltinFunction bind(PyObject self) {
0273:                        return new exposed___floordiv__(self, info);
0274:                    }
0275:
0276:                    public PyObject __call__(PyObject arg0) {
0277:                        PyObject ret = ((PyLong) self).long___floordiv__(arg0);
0278:                        if (ret == null)
0279:                            return Py.NotImplemented;
0280:                        return ret;
0281:                    }
0282:
0283:                }
0284:                dict.__setitem__("__floordiv__", new PyMethodDescr(
0285:                        "__floordiv__", PyLong.class, 1, 1,
0286:                        new exposed___floordiv__(null, null)));
0287:                class exposed___lshift__ extends PyBuiltinMethodNarrow {
0288:
0289:                    exposed___lshift__(PyObject self,
0290:                            PyBuiltinFunction.Info info) {
0291:                        super (self, info);
0292:                    }
0293:
0294:                    public PyBuiltinFunction bind(PyObject self) {
0295:                        return new exposed___lshift__(self, info);
0296:                    }
0297:
0298:                    public PyObject __call__(PyObject arg0) {
0299:                        PyObject ret = ((PyLong) self).long___lshift__(arg0);
0300:                        if (ret == null)
0301:                            return Py.NotImplemented;
0302:                        return ret;
0303:                    }
0304:
0305:                }
0306:                dict
0307:                        .__setitem__("__lshift__", new PyMethodDescr(
0308:                                "__lshift__", PyLong.class, 1, 1,
0309:                                new exposed___lshift__(null, null)));
0310:                class exposed___mod__ extends PyBuiltinMethodNarrow {
0311:
0312:                    exposed___mod__(PyObject self, PyBuiltinFunction.Info info) {
0313:                        super (self, info);
0314:                    }
0315:
0316:                    public PyBuiltinFunction bind(PyObject self) {
0317:                        return new exposed___mod__(self, info);
0318:                    }
0319:
0320:                    public PyObject __call__(PyObject arg0) {
0321:                        PyObject ret = ((PyLong) self).long___mod__(arg0);
0322:                        if (ret == null)
0323:                            return Py.NotImplemented;
0324:                        return ret;
0325:                    }
0326:
0327:                }
0328:                dict.__setitem__("__mod__", new PyMethodDescr("__mod__",
0329:                        PyLong.class, 1, 1, new exposed___mod__(null, null)));
0330:                class exposed___mul__ extends PyBuiltinMethodNarrow {
0331:
0332:                    exposed___mul__(PyObject self, PyBuiltinFunction.Info info) {
0333:                        super (self, info);
0334:                    }
0335:
0336:                    public PyBuiltinFunction bind(PyObject self) {
0337:                        return new exposed___mul__(self, info);
0338:                    }
0339:
0340:                    public PyObject __call__(PyObject arg0) {
0341:                        PyObject ret = ((PyLong) self).long___mul__(arg0);
0342:                        if (ret == null)
0343:                            return Py.NotImplemented;
0344:                        return ret;
0345:                    }
0346:
0347:                }
0348:                dict.__setitem__("__mul__", new PyMethodDescr("__mul__",
0349:                        PyLong.class, 1, 1, new exposed___mul__(null, null)));
0350:                class exposed___or__ extends PyBuiltinMethodNarrow {
0351:
0352:                    exposed___or__(PyObject self, PyBuiltinFunction.Info info) {
0353:                        super (self, info);
0354:                    }
0355:
0356:                    public PyBuiltinFunction bind(PyObject self) {
0357:                        return new exposed___or__(self, info);
0358:                    }
0359:
0360:                    public PyObject __call__(PyObject arg0) {
0361:                        PyObject ret = ((PyLong) self).long___or__(arg0);
0362:                        if (ret == null)
0363:                            return Py.NotImplemented;
0364:                        return ret;
0365:                    }
0366:
0367:                }
0368:                dict.__setitem__("__or__", new PyMethodDescr("__or__",
0369:                        PyLong.class, 1, 1, new exposed___or__(null, null)));
0370:                class exposed___radd__ extends PyBuiltinMethodNarrow {
0371:
0372:                    exposed___radd__(PyObject self, PyBuiltinFunction.Info info) {
0373:                        super (self, info);
0374:                    }
0375:
0376:                    public PyBuiltinFunction bind(PyObject self) {
0377:                        return new exposed___radd__(self, info);
0378:                    }
0379:
0380:                    public PyObject __call__(PyObject arg0) {
0381:                        PyObject ret = ((PyLong) self).long___radd__(arg0);
0382:                        if (ret == null)
0383:                            return Py.NotImplemented;
0384:                        return ret;
0385:                    }
0386:
0387:                }
0388:                dict.__setitem__("__radd__", new PyMethodDescr("__radd__",
0389:                        PyLong.class, 1, 1, new exposed___radd__(null, null)));
0390:                class exposed___rdiv__ extends PyBuiltinMethodNarrow {
0391:
0392:                    exposed___rdiv__(PyObject self, PyBuiltinFunction.Info info) {
0393:                        super (self, info);
0394:                    }
0395:
0396:                    public PyBuiltinFunction bind(PyObject self) {
0397:                        return new exposed___rdiv__(self, info);
0398:                    }
0399:
0400:                    public PyObject __call__(PyObject arg0) {
0401:                        PyObject ret = ((PyLong) self).long___rdiv__(arg0);
0402:                        if (ret == null)
0403:                            return Py.NotImplemented;
0404:                        return ret;
0405:                    }
0406:
0407:                }
0408:                dict.__setitem__("__rdiv__", new PyMethodDescr("__rdiv__",
0409:                        PyLong.class, 1, 1, new exposed___rdiv__(null, null)));
0410:                class exposed___rfloordiv__ extends PyBuiltinMethodNarrow {
0411:
0412:                    exposed___rfloordiv__(PyObject self,
0413:                            PyBuiltinFunction.Info info) {
0414:                        super (self, info);
0415:                    }
0416:
0417:                    public PyBuiltinFunction bind(PyObject self) {
0418:                        return new exposed___rfloordiv__(self, info);
0419:                    }
0420:
0421:                    public PyObject __call__(PyObject arg0) {
0422:                        PyObject ret = ((PyLong) self).long___rfloordiv__(arg0);
0423:                        if (ret == null)
0424:                            return Py.NotImplemented;
0425:                        return ret;
0426:                    }
0427:
0428:                }
0429:                dict.__setitem__("__rfloordiv__", new PyMethodDescr(
0430:                        "__rfloordiv__", PyLong.class, 1, 1,
0431:                        new exposed___rfloordiv__(null, null)));
0432:                class exposed___rmod__ extends PyBuiltinMethodNarrow {
0433:
0434:                    exposed___rmod__(PyObject self, PyBuiltinFunction.Info info) {
0435:                        super (self, info);
0436:                    }
0437:
0438:                    public PyBuiltinFunction bind(PyObject self) {
0439:                        return new exposed___rmod__(self, info);
0440:                    }
0441:
0442:                    public PyObject __call__(PyObject arg0) {
0443:                        PyObject ret = ((PyLong) self).long___rmod__(arg0);
0444:                        if (ret == null)
0445:                            return Py.NotImplemented;
0446:                        return ret;
0447:                    }
0448:
0449:                }
0450:                dict.__setitem__("__rmod__", new PyMethodDescr("__rmod__",
0451:                        PyLong.class, 1, 1, new exposed___rmod__(null, null)));
0452:                class exposed___rmul__ extends PyBuiltinMethodNarrow {
0453:
0454:                    exposed___rmul__(PyObject self, PyBuiltinFunction.Info info) {
0455:                        super (self, info);
0456:                    }
0457:
0458:                    public PyBuiltinFunction bind(PyObject self) {
0459:                        return new exposed___rmul__(self, info);
0460:                    }
0461:
0462:                    public PyObject __call__(PyObject arg0) {
0463:                        PyObject ret = ((PyLong) self).long___rmul__(arg0);
0464:                        if (ret == null)
0465:                            return Py.NotImplemented;
0466:                        return ret;
0467:                    }
0468:
0469:                }
0470:                dict.__setitem__("__rmul__", new PyMethodDescr("__rmul__",
0471:                        PyLong.class, 1, 1, new exposed___rmul__(null, null)));
0472:                class exposed___rshift__ extends PyBuiltinMethodNarrow {
0473:
0474:                    exposed___rshift__(PyObject self,
0475:                            PyBuiltinFunction.Info info) {
0476:                        super (self, info);
0477:                    }
0478:
0479:                    public PyBuiltinFunction bind(PyObject self) {
0480:                        return new exposed___rshift__(self, info);
0481:                    }
0482:
0483:                    public PyObject __call__(PyObject arg0) {
0484:                        PyObject ret = ((PyLong) self).long___rshift__(arg0);
0485:                        if (ret == null)
0486:                            return Py.NotImplemented;
0487:                        return ret;
0488:                    }
0489:
0490:                }
0491:                dict
0492:                        .__setitem__("__rshift__", new PyMethodDescr(
0493:                                "__rshift__", PyLong.class, 1, 1,
0494:                                new exposed___rshift__(null, null)));
0495:                class exposed___rsub__ extends PyBuiltinMethodNarrow {
0496:
0497:                    exposed___rsub__(PyObject self, PyBuiltinFunction.Info info) {
0498:                        super (self, info);
0499:                    }
0500:
0501:                    public PyBuiltinFunction bind(PyObject self) {
0502:                        return new exposed___rsub__(self, info);
0503:                    }
0504:
0505:                    public PyObject __call__(PyObject arg0) {
0506:                        PyObject ret = ((PyLong) self).long___rsub__(arg0);
0507:                        if (ret == null)
0508:                            return Py.NotImplemented;
0509:                        return ret;
0510:                    }
0511:
0512:                }
0513:                dict.__setitem__("__rsub__", new PyMethodDescr("__rsub__",
0514:                        PyLong.class, 1, 1, new exposed___rsub__(null, null)));
0515:                class exposed___rtruediv__ extends PyBuiltinMethodNarrow {
0516:
0517:                    exposed___rtruediv__(PyObject self,
0518:                            PyBuiltinFunction.Info info) {
0519:                        super (self, info);
0520:                    }
0521:
0522:                    public PyBuiltinFunction bind(PyObject self) {
0523:                        return new exposed___rtruediv__(self, info);
0524:                    }
0525:
0526:                    public PyObject __call__(PyObject arg0) {
0527:                        PyObject ret = ((PyLong) self).long___rtruediv__(arg0);
0528:                        if (ret == null)
0529:                            return Py.NotImplemented;
0530:                        return ret;
0531:                    }
0532:
0533:                }
0534:                dict.__setitem__("__rtruediv__", new PyMethodDescr(
0535:                        "__rtruediv__", PyLong.class, 1, 1,
0536:                        new exposed___rtruediv__(null, null)));
0537:                class exposed___sub__ extends PyBuiltinMethodNarrow {
0538:
0539:                    exposed___sub__(PyObject self, PyBuiltinFunction.Info info) {
0540:                        super (self, info);
0541:                    }
0542:
0543:                    public PyBuiltinFunction bind(PyObject self) {
0544:                        return new exposed___sub__(self, info);
0545:                    }
0546:
0547:                    public PyObject __call__(PyObject arg0) {
0548:                        PyObject ret = ((PyLong) self).long___sub__(arg0);
0549:                        if (ret == null)
0550:                            return Py.NotImplemented;
0551:                        return ret;
0552:                    }
0553:
0554:                }
0555:                dict.__setitem__("__sub__", new PyMethodDescr("__sub__",
0556:                        PyLong.class, 1, 1, new exposed___sub__(null, null)));
0557:                class exposed___truediv__ extends PyBuiltinMethodNarrow {
0558:
0559:                    exposed___truediv__(PyObject self,
0560:                            PyBuiltinFunction.Info info) {
0561:                        super (self, info);
0562:                    }
0563:
0564:                    public PyBuiltinFunction bind(PyObject self) {
0565:                        return new exposed___truediv__(self, info);
0566:                    }
0567:
0568:                    public PyObject __call__(PyObject arg0) {
0569:                        PyObject ret = ((PyLong) self).long___truediv__(arg0);
0570:                        if (ret == null)
0571:                            return Py.NotImplemented;
0572:                        return ret;
0573:                    }
0574:
0575:                }
0576:                dict.__setitem__("__truediv__", new PyMethodDescr(
0577:                        "__truediv__", PyLong.class, 1, 1,
0578:                        new exposed___truediv__(null, null)));
0579:                class exposed___xor__ extends PyBuiltinMethodNarrow {
0580:
0581:                    exposed___xor__(PyObject self, PyBuiltinFunction.Info info) {
0582:                        super (self, info);
0583:                    }
0584:
0585:                    public PyBuiltinFunction bind(PyObject self) {
0586:                        return new exposed___xor__(self, info);
0587:                    }
0588:
0589:                    public PyObject __call__(PyObject arg0) {
0590:                        PyObject ret = ((PyLong) self).long___xor__(arg0);
0591:                        if (ret == null)
0592:                            return Py.NotImplemented;
0593:                        return ret;
0594:                    }
0595:
0596:                }
0597:                dict.__setitem__("__xor__", new PyMethodDescr("__xor__",
0598:                        PyLong.class, 1, 1, new exposed___xor__(null, null)));
0599:                class exposed___rxor__ extends PyBuiltinMethodNarrow {
0600:
0601:                    exposed___rxor__(PyObject self, PyBuiltinFunction.Info info) {
0602:                        super (self, info);
0603:                    }
0604:
0605:                    public PyBuiltinFunction bind(PyObject self) {
0606:                        return new exposed___rxor__(self, info);
0607:                    }
0608:
0609:                    public PyObject __call__(PyObject arg0) {
0610:                        PyObject ret = ((PyLong) self).long___rxor__(arg0);
0611:                        if (ret == null)
0612:                            return Py.NotImplemented;
0613:                        return ret;
0614:                    }
0615:
0616:                }
0617:                dict.__setitem__("__rxor__", new PyMethodDescr("__rxor__",
0618:                        PyLong.class, 1, 1, new exposed___rxor__(null, null)));
0619:                class exposed___rrshift__ extends PyBuiltinMethodNarrow {
0620:
0621:                    exposed___rrshift__(PyObject self,
0622:                            PyBuiltinFunction.Info info) {
0623:                        super (self, info);
0624:                    }
0625:
0626:                    public PyBuiltinFunction bind(PyObject self) {
0627:                        return new exposed___rrshift__(self, info);
0628:                    }
0629:
0630:                    public PyObject __call__(PyObject arg0) {
0631:                        PyObject ret = ((PyLong) self).long___rrshift__(arg0);
0632:                        if (ret == null)
0633:                            return Py.NotImplemented;
0634:                        return ret;
0635:                    }
0636:
0637:                }
0638:                dict.__setitem__("__rrshift__", new PyMethodDescr(
0639:                        "__rrshift__", PyLong.class, 1, 1,
0640:                        new exposed___rrshift__(null, null)));
0641:                class exposed___ror__ extends PyBuiltinMethodNarrow {
0642:
0643:                    exposed___ror__(PyObject self, PyBuiltinFunction.Info info) {
0644:                        super (self, info);
0645:                    }
0646:
0647:                    public PyBuiltinFunction bind(PyObject self) {
0648:                        return new exposed___ror__(self, info);
0649:                    }
0650:
0651:                    public PyObject __call__(PyObject arg0) {
0652:                        PyObject ret = ((PyLong) self).long___ror__(arg0);
0653:                        if (ret == null)
0654:                            return Py.NotImplemented;
0655:                        return ret;
0656:                    }
0657:
0658:                }
0659:                dict.__setitem__("__ror__", new PyMethodDescr("__ror__",
0660:                        PyLong.class, 1, 1, new exposed___ror__(null, null)));
0661:                class exposed___rand__ extends PyBuiltinMethodNarrow {
0662:
0663:                    exposed___rand__(PyObject self, PyBuiltinFunction.Info info) {
0664:                        super (self, info);
0665:                    }
0666:
0667:                    public PyBuiltinFunction bind(PyObject self) {
0668:                        return new exposed___rand__(self, info);
0669:                    }
0670:
0671:                    public PyObject __call__(PyObject arg0) {
0672:                        PyObject ret = ((PyLong) self).long___rand__(arg0);
0673:                        if (ret == null)
0674:                            return Py.NotImplemented;
0675:                        return ret;
0676:                    }
0677:
0678:                }
0679:                dict.__setitem__("__rand__", new PyMethodDescr("__rand__",
0680:                        PyLong.class, 1, 1, new exposed___rand__(null, null)));
0681:                class exposed___rpow__ extends PyBuiltinMethodNarrow {
0682:
0683:                    exposed___rpow__(PyObject self, PyBuiltinFunction.Info info) {
0684:                        super (self, info);
0685:                    }
0686:
0687:                    public PyBuiltinFunction bind(PyObject self) {
0688:                        return new exposed___rpow__(self, info);
0689:                    }
0690:
0691:                    public PyObject __call__(PyObject arg0) {
0692:                        PyObject ret = ((PyLong) self).long___rpow__(arg0);
0693:                        if (ret == null)
0694:                            return Py.NotImplemented;
0695:                        return ret;
0696:                    }
0697:
0698:                }
0699:                dict.__setitem__("__rpow__", new PyMethodDescr("__rpow__",
0700:                        PyLong.class, 1, 1, new exposed___rpow__(null, null)));
0701:                class exposed___rlshift__ extends PyBuiltinMethodNarrow {
0702:
0703:                    exposed___rlshift__(PyObject self,
0704:                            PyBuiltinFunction.Info info) {
0705:                        super (self, info);
0706:                    }
0707:
0708:                    public PyBuiltinFunction bind(PyObject self) {
0709:                        return new exposed___rlshift__(self, info);
0710:                    }
0711:
0712:                    public PyObject __call__(PyObject arg0) {
0713:                        PyObject ret = ((PyLong) self).long___rlshift__(arg0);
0714:                        if (ret == null)
0715:                            return Py.NotImplemented;
0716:                        return ret;
0717:                    }
0718:
0719:                }
0720:                dict.__setitem__("__rlshift__", new PyMethodDescr(
0721:                        "__rlshift__", PyLong.class, 1, 1,
0722:                        new exposed___rlshift__(null, null)));
0723:                class exposed___rdivmod__ extends PyBuiltinMethodNarrow {
0724:
0725:                    exposed___rdivmod__(PyObject self,
0726:                            PyBuiltinFunction.Info info) {
0727:                        super (self, info);
0728:                    }
0729:
0730:                    public PyBuiltinFunction bind(PyObject self) {
0731:                        return new exposed___rdivmod__(self, info);
0732:                    }
0733:
0734:                    public PyObject __call__(PyObject arg0) {
0735:                        PyObject ret = ((PyLong) self).long___rdivmod__(arg0);
0736:                        if (ret == null)
0737:                            return Py.NotImplemented;
0738:                        return ret;
0739:                    }
0740:
0741:                }
0742:                dict.__setitem__("__rdivmod__", new PyMethodDescr(
0743:                        "__rdivmod__", PyLong.class, 1, 1,
0744:                        new exposed___rdivmod__(null, null)));
0745:                class exposed___cmp__ extends PyBuiltinMethodNarrow {
0746:
0747:                    exposed___cmp__(PyObject self, PyBuiltinFunction.Info info) {
0748:                        super (self, info);
0749:                    }
0750:
0751:                    public PyBuiltinFunction bind(PyObject self) {
0752:                        return new exposed___cmp__(self, info);
0753:                    }
0754:
0755:                    public PyObject __call__(PyObject arg0) {
0756:                        int ret = ((PyLong) self).long___cmp__(arg0);
0757:                        if (ret == -2) {
0758:                            throw Py.TypeError("long"
0759:                                    + ".__cmp__(x,y) requires y to be '"
0760:                                    + "long" + "', not a '"
0761:                                    + (arg0).getType().fastGetName() + "'");
0762:                        }
0763:                        return Py.newInteger(ret);
0764:                    }
0765:
0766:                }
0767:                dict.__setitem__("__cmp__", new PyMethodDescr("__cmp__",
0768:                        PyLong.class, 1, 1, new exposed___cmp__(null, null)));
0769:                class exposed___pow__ extends PyBuiltinMethodNarrow {
0770:
0771:                    exposed___pow__(PyObject self, PyBuiltinFunction.Info info) {
0772:                        super (self, info);
0773:                    }
0774:
0775:                    public PyBuiltinFunction bind(PyObject self) {
0776:                        return new exposed___pow__(self, info);
0777:                    }
0778:
0779:                    public PyObject __call__(PyObject arg0, PyObject arg1) {
0780:                        PyObject ret = ((PyLong) self).long___pow__(arg0, arg1);
0781:                        if (ret == null)
0782:                            return Py.NotImplemented;
0783:                        return ret;
0784:                    }
0785:
0786:                    public PyObject __call__(PyObject arg0) {
0787:                        PyObject ret = ((PyLong) self).long___pow__(arg0, null);
0788:                        if (ret == null)
0789:                            return Py.NotImplemented;
0790:                        return ret;
0791:                    }
0792:
0793:                }
0794:                dict.__setitem__("__pow__", new PyMethodDescr("__pow__",
0795:                        PyLong.class, 1, 2, new exposed___pow__(null, null)));
0796:                class exposed___nonzero__ extends PyBuiltinMethodNarrow {
0797:
0798:                    exposed___nonzero__(PyObject self,
0799:                            PyBuiltinFunction.Info info) {
0800:                        super (self, info);
0801:                    }
0802:
0803:                    public PyBuiltinFunction bind(PyObject self) {
0804:                        return new exposed___nonzero__(self, info);
0805:                    }
0806:
0807:                    public PyObject __call__() {
0808:                        return Py
0809:                                .newBoolean(((PyLong) self).long___nonzero__());
0810:                    }
0811:
0812:                }
0813:                dict.__setitem__("__nonzero__", new PyMethodDescr(
0814:                        "__nonzero__", PyLong.class, 0, 0,
0815:                        new exposed___nonzero__(null, null)));
0816:                class exposed___repr__ extends PyBuiltinMethodNarrow {
0817:
0818:                    exposed___repr__(PyObject self, PyBuiltinFunction.Info info) {
0819:                        super (self, info);
0820:                    }
0821:
0822:                    public PyBuiltinFunction bind(PyObject self) {
0823:                        return new exposed___repr__(self, info);
0824:                    }
0825:
0826:                    public PyObject __call__() {
0827:                        return new PyString(((PyLong) self).long_toString());
0828:                    }
0829:
0830:                }
0831:                dict.__setitem__("__repr__", new PyMethodDescr("__repr__",
0832:                        PyLong.class, 0, 0, new exposed___repr__(null, null)));
0833:                class exposed___str__ extends PyBuiltinMethodNarrow {
0834:
0835:                    exposed___str__(PyObject self, PyBuiltinFunction.Info info) {
0836:                        super (self, info);
0837:                    }
0838:
0839:                    public PyBuiltinFunction bind(PyObject self) {
0840:                        return new exposed___str__(self, info);
0841:                    }
0842:
0843:                    public PyObject __call__() {
0844:                        return new PyString(((PyLong) self).long_toString());
0845:                    }
0846:
0847:                }
0848:                dict.__setitem__("__str__", new PyMethodDescr("__str__",
0849:                        PyLong.class, 0, 0, new exposed___str__(null, null)));
0850:                class exposed___hash__ extends PyBuiltinMethodNarrow {
0851:
0852:                    exposed___hash__(PyObject self, PyBuiltinFunction.Info info) {
0853:                        super (self, info);
0854:                    }
0855:
0856:                    public PyBuiltinFunction bind(PyObject self) {
0857:                        return new exposed___hash__(self, info);
0858:                    }
0859:
0860:                    public PyObject __call__() {
0861:                        return Py.newInteger(((PyLong) self).long_hashCode());
0862:                    }
0863:
0864:                }
0865:                dict.__setitem__("__hash__", new PyMethodDescr("__hash__",
0866:                        PyLong.class, 0, 0, new exposed___hash__(null, null)));
0867:                dict.__setitem__("__new__", new PyNewWrapper(PyLong.class,
0868:                        "__new__", -1, -1) {
0869:
0870:                    public PyObject new_impl(boolean init, PyType subtype,
0871:                            PyObject[] args, String[] keywords) {
0872:                        return long_new(this , init, subtype, args, keywords);
0873:                    }
0874:
0875:                });
0876:            }
0877:
0878:            //~ END GENERATED REGION -- DO NOT EDIT SEE gexpose.py
0879:
0880:            private BigInteger value;
0881:
0882:            public static PyObject long_new(PyNewWrapper new_, boolean init,
0883:                    PyType subtype, PyObject[] args, String[] keywords) {
0884:
0885:                ArgParser ap = new ArgParser(exposed_name, args, keywords,
0886:                        new String[] { "x", "base" }, 0);
0887:
0888:                PyObject x = ap.getPyObject(0, null);
0889:                int base = ap.getInt(1, -909);
0890:                if (new_.for_type == subtype) {
0891:                    if (x == null) {
0892:                        return Py.Zero;
0893:                    }
0894:
0895:                    Object o = x.__tojava__(BigInteger.class);
0896:                    if (o != Py.NoConversion) {
0897:                        return Py.newLong((BigInteger) o);
0898:                    }
0899:
0900:                    if (base == -909) {
0901:                        return x.__long__();
0902:                    }
0903:
0904:                    if (!(x instanceof  PyString)) {
0905:                        throw Py
0906:                                .TypeError("long: can't convert non-string with explicit base");
0907:                    }
0908:
0909:                    return ((PyString) x).atol(base);
0910:                } else {
0911:                    if (x == null) {
0912:                        return new PyLongDerived(subtype, BigInteger.valueOf(0));
0913:                    }
0914:                    Object o = x.__tojava__(BigInteger.class);
0915:                    if (o != Py.NoConversion) {
0916:                        return new PyLongDerived(subtype, (BigInteger) o);
0917:                    }
0918:
0919:                    if (base == -909) {
0920:                        return new PyLongDerived(subtype, x.__long__()
0921:                                .getValue());
0922:                    }
0923:
0924:                    if (!(x instanceof  PyString)) {
0925:                        throw Py
0926:                                .TypeError("long: can't convert non-string with explicit base");
0927:                    }
0928:
0929:                    return new PyLongDerived(subtype, (((PyString) x)
0930:                            .atol(base)).getValue());
0931:                }
0932:            } // xxx
0933:
0934:            private static final PyType LONGTYPE = PyType
0935:                    .fromClass(PyLong.class);
0936:
0937:            public PyLong(PyType subType, BigInteger v) {
0938:                super (subType);
0939:                value = v;
0940:            }
0941:
0942:            public PyLong(BigInteger v) {
0943:                this (LONGTYPE, v);
0944:            }
0945:
0946:            public PyLong(double v) {
0947:                this (new java.math.BigDecimal(v).toBigInteger());
0948:            }
0949:
0950:            public PyLong(long v) {
0951:                this (BigInteger.valueOf(v));
0952:            }
0953:
0954:            public PyLong(String s) {
0955:                this (new BigInteger(s));
0956:            }
0957:
0958:            public BigInteger getValue() {
0959:                return value;
0960:            }
0961:
0962:            public String toString() {
0963:                return long_toString();
0964:            }
0965:
0966:            final String long_toString() {
0967:                return value.toString() + "L";
0968:            }
0969:
0970:            public int hashCode() {
0971:                return long_hashCode();
0972:            }
0973:
0974:            final int long_hashCode() {
0975:                // Probably won't work well for some classes of keys...
0976:                return value.intValue();
0977:            }
0978:
0979:            public boolean __nonzero__() {
0980:                return !value.equals(BigInteger.valueOf(0));
0981:            }
0982:
0983:            public boolean long___nonzero__() {
0984:                return __nonzero__();
0985:            }
0986:
0987:            public double doubleValue() {
0988:                double v = value.doubleValue();
0989:                if (v == Double.NEGATIVE_INFINITY
0990:                        || v == Double.POSITIVE_INFINITY) {
0991:                    throw Py.OverflowError("long int too long to convert");
0992:                }
0993:                return v;
0994:            }
0995:
0996:            private static final double scaledDoubleValue(BigInteger val,
0997:                    int[] exp) {
0998:                double x = 0;
0999:                int signum = val.signum();
1000:                byte[] digits;
1001:
1002:                if (signum >= 0) {
1003:                    digits = val.toByteArray();
1004:                } else {
1005:                    digits = val.negate().toByteArray();
1006:                }
1007:
1008:                int count = 8;
1009:                int i = 0;
1010:
1011:                if (digits[0] == 0) {
1012:                    i++;
1013:                    count++;
1014:                }
1015:                count = count <= digits.length ? count : digits.length;
1016:
1017:                while (i < count) {
1018:                    x = x * 256 + (digits[i] & 0xff);
1019:                    i++;
1020:                }
1021:                exp[0] = digits.length - i;
1022:                return signum * x;
1023:            }
1024:
1025:            public double scaledDoubleValue(int[] exp) {
1026:                return scaledDoubleValue(value, exp);
1027:            }
1028:
1029:            private long getLong(long min, long max) {
1030:                if (value.compareTo(maxLong) <= 0
1031:                        && value.compareTo(minLong) >= 0) {
1032:                    long v = value.longValue();
1033:                    if (v >= min && v <= max)
1034:                        return v;
1035:                }
1036:                throw Py.OverflowError("long int too long to convert");
1037:            }
1038:
1039:            public long asLong(int index) {
1040:                return getLong(Long.MIN_VALUE, Long.MAX_VALUE);
1041:            }
1042:
1043:            public Object __tojava__(Class c) {
1044:                try {
1045:                    if (c == Byte.TYPE || c == Byte.class) {
1046:                        return new Byte((byte) getLong(Byte.MIN_VALUE,
1047:                                Byte.MAX_VALUE));
1048:                    }
1049:                    if (c == Short.TYPE || c == Short.class) {
1050:                        return new Short((short) getLong(Short.MIN_VALUE,
1051:                                Short.MAX_VALUE));
1052:                    }
1053:                    if (c == Integer.TYPE || c == Integer.class) {
1054:                        return new Integer((int) getLong(Integer.MIN_VALUE,
1055:                                Integer.MAX_VALUE));
1056:                    }
1057:                    if (c == Long.TYPE || c == Long.class) {
1058:                        return new Long(getLong(Long.MIN_VALUE, Long.MAX_VALUE));
1059:                    }
1060:                    if (c == Float.TYPE || c == Double.TYPE || c == Float.class
1061:                            || c == Double.class) {
1062:                        return __float__().__tojava__(c);
1063:                    }
1064:                    if (c == BigInteger.class || c == Number.class
1065:                            || c == Object.class || c == Serializable.class) {
1066:                        return value;
1067:                    }
1068:                } catch (PyException e) {
1069:                    return Py.NoConversion;
1070:                }
1071:                return super .__tojava__(c);
1072:            }
1073:
1074:            public int __cmp__(PyObject other) {
1075:                return long___cmp__(other);
1076:            }
1077:
1078:            final int long___cmp__(PyObject other) {
1079:                if (!canCoerce(other))
1080:                    return -2;
1081:                return value.compareTo(coerce(other));
1082:            }
1083:
1084:            public Object __coerce_ex__(PyObject other) {
1085:                if (other instanceof  PyLong)
1086:                    return other;
1087:                else if (other instanceof  PyInteger) {
1088:                    return Py.newLong(((PyInteger) other).getValue());
1089:                } else {
1090:                    return Py.None;
1091:                }
1092:            }
1093:
1094:            private static final boolean canCoerce(PyObject other) {
1095:                return other instanceof  PyLong || other instanceof  PyInteger;
1096:            }
1097:
1098:            private static final BigInteger coerce(PyObject other) {
1099:                if (other instanceof  PyLong)
1100:                    return ((PyLong) other).value;
1101:                else if (other instanceof  PyInteger)
1102:                    return BigInteger.valueOf(((PyInteger) other).getValue());
1103:                else
1104:                    throw Py.TypeError("xxx");
1105:            }
1106:
1107:            public PyObject __add__(PyObject right) {
1108:                return long___add__(right);
1109:            }
1110:
1111:            final PyObject long___add__(PyObject right) {
1112:                if (!canCoerce(right))
1113:                    return null;
1114:                return Py.newLong(value.add(coerce(right)));
1115:            }
1116:
1117:            public PyObject __radd__(PyObject left) {
1118:                return long___radd__(left);
1119:            }
1120:
1121:            final PyObject long___radd__(PyObject left) {
1122:                return __add__(left);
1123:            }
1124:
1125:            public PyObject __sub__(PyObject right) {
1126:                return long___sub__(right);
1127:            }
1128:
1129:            final PyObject long___sub__(PyObject right) {
1130:                if (!canCoerce(right))
1131:                    return null;
1132:                return Py.newLong(value.subtract(coerce(right)));
1133:            }
1134:
1135:            public PyObject __rsub__(PyObject left) {
1136:                return long___rsub__(left);
1137:            }
1138:
1139:            final PyObject long___rsub__(PyObject left) {
1140:                return Py.newLong(coerce(left).subtract(value));
1141:            }
1142:
1143:            public PyObject __mul__(PyObject right) {
1144:                return long___mul__(right);
1145:            }
1146:
1147:            final PyObject long___mul__(PyObject right) {
1148:                if (right instanceof  PySequence)
1149:                    return ((PySequence) right).repeat(coerceInt(this ));
1150:
1151:                if (!canCoerce(right))
1152:                    return null;
1153:                return Py.newLong(value.multiply(coerce(right)));
1154:            }
1155:
1156:            public PyObject __rmul__(PyObject left) {
1157:                return long___rmul__(left);
1158:            }
1159:
1160:            final PyObject long___rmul__(PyObject left) {
1161:                if (left instanceof  PySequence)
1162:                    return ((PySequence) left).repeat(coerceInt(this ));
1163:                if (!canCoerce(left))
1164:                    return null;
1165:                return Py.newLong(coerce(left).multiply(value));
1166:            }
1167:
1168:            // Getting signs correct for integer division
1169:            // This convention makes sense when you consider it in tandem with modulo
1170:            private BigInteger divide(BigInteger x, BigInteger y) {
1171:                BigInteger zero = BigInteger.valueOf(0);
1172:                if (y.equals(zero))
1173:                    throw Py.ZeroDivisionError("long division or modulo");
1174:
1175:                if (y.compareTo(zero) < 0) {
1176:                    if (x.compareTo(zero) > 0)
1177:                        return (x.subtract(y).subtract(BigInteger.valueOf(1)))
1178:                                .divide(y);
1179:                } else {
1180:                    if (x.compareTo(zero) < 0)
1181:                        return (x.subtract(y).add(BigInteger.valueOf(1)))
1182:                                .divide(y);
1183:                }
1184:                return x.divide(y);
1185:            }
1186:
1187:            public PyObject __div__(PyObject right) {
1188:                return long___div__(right);
1189:            }
1190:
1191:            final PyObject long___div__(PyObject right) {
1192:                if (!canCoerce(right))
1193:                    return null;
1194:                if (Options.divisionWarning > 0)
1195:                    Py.warning(Py.DeprecationWarning, "classic long division");
1196:                return Py.newLong(divide(value, coerce(right)));
1197:            }
1198:
1199:            public PyObject __rdiv__(PyObject left) {
1200:                return long___rdiv__(left);
1201:            }
1202:
1203:            final PyObject long___rdiv__(PyObject left) {
1204:                if (!canCoerce(left))
1205:                    return null;
1206:                if (Options.divisionWarning > 0)
1207:                    Py.warning(Py.DeprecationWarning, "classic long division");
1208:                return Py.newLong(divide(coerce(left), value));
1209:            }
1210:
1211:            public PyObject __floordiv__(PyObject right) {
1212:                return long___floordiv__(right);
1213:            }
1214:
1215:            final PyObject long___floordiv__(PyObject right) {
1216:                if (!canCoerce(right))
1217:                    return null;
1218:                return Py.newLong(divide(value, coerce(right)));
1219:            }
1220:
1221:            public PyObject __rfloordiv__(PyObject left) {
1222:                return long___rfloordiv__(left);
1223:            }
1224:
1225:            final PyObject long___rfloordiv__(PyObject left) {
1226:                if (!canCoerce(left))
1227:                    return null;
1228:                return Py.newLong(divide(coerce(left), value));
1229:            }
1230:
1231:            private static final PyFloat true_divide(BigInteger a, BigInteger b) {
1232:                int[] ae = new int[1];
1233:                int[] be = new int[1];
1234:                double ad, bd;
1235:
1236:                ad = scaledDoubleValue(a, ae);
1237:                bd = scaledDoubleValue(b, be);
1238:
1239:                if (bd == 0)
1240:                    throw Py.ZeroDivisionError("long division or modulo");
1241:
1242:                ad /= bd;
1243:                int aexp = ae[0] - be[0];
1244:
1245:                if (aexp > Integer.MAX_VALUE / 8) {
1246:                    throw Py.OverflowError("long/long too large for a float");
1247:                } else if (aexp < -(Integer.MAX_VALUE / 8)) {
1248:                    return new PyFloat(0.0);
1249:                }
1250:
1251:                ad = ad * Math.pow(2.0, aexp * 8);
1252:
1253:                if (Double.isInfinite(ad)) {
1254:                    throw Py.OverflowError("long/long too large for a float");
1255:                }
1256:
1257:                return new PyFloat(ad);
1258:            }
1259:
1260:            public PyObject __truediv__(PyObject right) {
1261:                return long___truediv__(right);
1262:            }
1263:
1264:            final PyObject long___truediv__(PyObject right) {
1265:                if (!canCoerce(right))
1266:                    return null;
1267:                return true_divide(this .value, coerce(right));
1268:            }
1269:
1270:            public PyObject __rtruediv__(PyObject left) {
1271:                return long___rtruediv__(left);
1272:            }
1273:
1274:            final PyObject long___rtruediv__(PyObject left) {
1275:                if (!canCoerce(left))
1276:                    return null;
1277:                return true_divide(coerce(left), this .value);
1278:            }
1279:
1280:            private BigInteger modulo(BigInteger x, BigInteger y,
1281:                    BigInteger xdivy) {
1282:                return x.subtract(xdivy.multiply(y));
1283:            }
1284:
1285:            public PyObject __mod__(PyObject right) {
1286:                return long___mod__(right);
1287:            }
1288:
1289:            final PyObject long___mod__(PyObject right) {
1290:                if (!canCoerce(right))
1291:                    return null;
1292:                BigInteger rightv = coerce(right);
1293:                return Py.newLong(modulo(value, rightv, divide(value, rightv)));
1294:            }
1295:
1296:            public PyObject __rmod__(PyObject left) {
1297:                return long___rmod__(left);
1298:            }
1299:
1300:            final PyObject long___rmod__(PyObject left) {
1301:                if (!canCoerce(left))
1302:                    return null;
1303:                BigInteger leftv = coerce(left);
1304:                return Py.newLong(modulo(leftv, value, divide(leftv, value)));
1305:            }
1306:
1307:            public PyObject __divmod__(PyObject right) {
1308:                return long___divmod__(right);
1309:            }
1310:
1311:            final PyObject long___divmod__(PyObject right) {
1312:                if (!canCoerce(right))
1313:                    return null;
1314:                BigInteger rightv = coerce(right);
1315:
1316:                BigInteger xdivy = divide(value, rightv);
1317:                return new PyTuple(new PyObject[] { Py.newLong(xdivy),
1318:                        Py.newLong(modulo(value, rightv, xdivy)) });
1319:            }
1320:
1321:            public PyObject __rdivmod__(PyObject left) {
1322:                return long___rdivmod__(left);
1323:            }
1324:
1325:            final PyObject long___rdivmod__(PyObject left) {
1326:                if (!canCoerce(left))
1327:                    return null;
1328:                BigInteger leftv = coerce(left);
1329:
1330:                BigInteger xdivy = divide(leftv, value);
1331:                return new PyTuple(new PyObject[] { Py.newLong(xdivy),
1332:                        Py.newLong(modulo(leftv, value, xdivy)) });
1333:            }
1334:
1335:            public PyObject __pow__(PyObject right, PyObject modulo) {
1336:                return long___pow__(right, modulo);
1337:            }
1338:
1339:            final PyObject long___pow__(PyObject right, PyObject modulo) {
1340:                if (!canCoerce(right))
1341:                    return null;
1342:
1343:                if (modulo != null && !canCoerce(right))
1344:                    return null;
1345:                return _pow(value, coerce(right), modulo, this , right);
1346:            }
1347:
1348:            public PyObject __rpow__(PyObject left) {
1349:                return long___rpow__(left);
1350:            }
1351:
1352:            final PyObject long___rpow__(PyObject left) {
1353:                if (!canCoerce(left))
1354:                    return null;
1355:                return _pow(coerce(left), value, null, left, this );
1356:            }
1357:
1358:            public static PyObject _pow(BigInteger value, BigInteger y,
1359:                    PyObject modulo, PyObject left, PyObject right) {
1360:                if (y.compareTo(BigInteger.valueOf(0)) < 0) {
1361:                    if (value.compareTo(BigInteger.valueOf(0)) != 0)
1362:                        return left.__float__().__pow__(right, modulo);
1363:                    else
1364:                        throw Py.ZeroDivisionError("zero to a negative power");
1365:                }
1366:                if (modulo == null)
1367:                    return Py.newLong(value.pow(y.intValue()));
1368:                else {
1369:                    // This whole thing can be trivially rewritten after bugs
1370:                    // in modPow are fixed by SUN
1371:
1372:                    BigInteger z = coerce(modulo);
1373:                    int zi = z.intValue();
1374:                    // Clear up some special cases right away
1375:                    if (zi == 0)
1376:                        throw Py.ValueError("pow(x, y, z) with z == 0");
1377:                    if (zi == 1 || zi == -1)
1378:                        return Py.newLong(0);
1379:
1380:                    if (z.compareTo(BigInteger.valueOf(0)) <= 0) {
1381:                        // Handle negative modulo's specially
1382:                        /*if (z.compareTo(BigInteger.valueOf(0)) == 0) {
1383:                          throw Py.ValueError("pow(x, y, z) with z == 0");
1384:                          }*/
1385:                        y = value.modPow(y, z.negate());
1386:                        if (y.compareTo(BigInteger.valueOf(0)) > 0) {
1387:                            return Py.newLong(z.add(y));
1388:                        } else {
1389:                            return Py.newLong(y);
1390:                        }
1391:                        //return __pow__(right).__mod__(modulo);
1392:                    } else {
1393:                        // XXX: 1.1 no longer supported so review this.
1394:                        // This is buggy in SUN's jdk1.1.5
1395:                        // Extra __mod__ improves things slightly
1396:                        return Py.newLong(value.modPow(y, z));
1397:                        //return __pow__(right).__mod__(modulo);
1398:                    }
1399:                }
1400:            }
1401:
1402:            private static final int coerceInt(PyObject other) {
1403:                if (other instanceof  PyLong)
1404:                    return (int) ((PyLong) other).getLong(Integer.MIN_VALUE,
1405:                            Integer.MAX_VALUE);
1406:                else if (other instanceof  PyInteger)
1407:                    return ((PyInteger) other).getValue();
1408:                else
1409:                    throw Py.TypeError("xxx");
1410:            }
1411:
1412:            public PyObject __lshift__(PyObject right) {
1413:                return long___lshift__(right);
1414:            }
1415:
1416:            final PyObject long___lshift__(PyObject right) {
1417:                if (!canCoerce(right))
1418:                    return null;
1419:                int rightv = coerceInt(right);
1420:                if (rightv < 0)
1421:                    throw Py.ValueError("negative shift count");
1422:                return Py.newLong(value.shiftLeft(rightv));
1423:            }
1424:
1425:            final PyObject long___rlshift__(PyObject left) {
1426:                if (!canCoerce(left))
1427:                    return null;
1428:                if (value.intValue() < 0)
1429:                    throw Py.ValueError("negative shift count");
1430:                return Py.newLong(coerce(left).shiftLeft(coerceInt(this )));
1431:            }
1432:
1433:            public PyObject __rshift__(PyObject right) {
1434:                return long___rshift__(right);
1435:            }
1436:
1437:            final PyObject long___rshift__(PyObject right) {
1438:                if (!canCoerce(right))
1439:                    return null;
1440:                int rightv = coerceInt(right);
1441:                if (rightv < 0)
1442:                    throw Py.ValueError("negative shift count");
1443:                return Py.newLong(value.shiftRight(rightv));
1444:            }
1445:
1446:            final PyObject long___rrshift__(PyObject left) {
1447:                if (!canCoerce(left))
1448:                    return null;
1449:                if (value.intValue() < 0)
1450:                    throw Py.ValueError("negative shift count");
1451:                return Py.newLong(coerce(left).shiftRight(coerceInt(this )));
1452:            }
1453:
1454:            public PyObject __and__(PyObject right) {
1455:                return long___and__(right);
1456:            }
1457:
1458:            final PyObject long___and__(PyObject right) {
1459:                if (!canCoerce(right))
1460:                    return null;
1461:                return Py.newLong(value.and(coerce(right)));
1462:            }
1463:
1464:            public PyObject __rand__(PyObject left) {
1465:                return long___rand__(left);
1466:            }
1467:
1468:            final PyObject long___rand__(PyObject left) {
1469:                if (!canCoerce(left))
1470:                    return null;
1471:                return Py.newLong(coerce(left).and(value));
1472:            }
1473:
1474:            public PyObject __xor__(PyObject right) {
1475:                return long___xor__(right);
1476:            }
1477:
1478:            final PyObject long___xor__(PyObject right) {
1479:                if (!canCoerce(right))
1480:                    return null;
1481:                return Py.newLong(value.xor(coerce(right)));
1482:            }
1483:
1484:            public PyObject __rxor__(PyObject left) {
1485:                return long___rxor__(left);
1486:            }
1487:
1488:            final PyObject long___rxor__(PyObject left) {
1489:                if (!canCoerce(left))
1490:                    return null;
1491:                return Py.newLong(coerce(left).xor(value));
1492:            }
1493:
1494:            public PyObject __or__(PyObject right) {
1495:                return long___or__(right);
1496:            }
1497:
1498:            final PyObject long___or__(PyObject right) {
1499:                if (!canCoerce(right))
1500:                    return null;
1501:                return Py.newLong(value.or(coerce(right)));
1502:            }
1503:
1504:            public PyObject __ror__(PyObject left) {
1505:                return long___ror__(left);
1506:            }
1507:
1508:            final PyObject long___ror__(PyObject left) {
1509:                if (!canCoerce(left))
1510:                    return null;
1511:                return Py.newLong(coerce(left).or(value));
1512:            }
1513:
1514:            public PyObject __neg__() {
1515:                return long___neg__();
1516:            }
1517:
1518:            final PyObject long___neg__() {
1519:                return Py.newLong(value.negate());
1520:            }
1521:
1522:            public PyObject __pos__() {
1523:                return long___pos__();
1524:            }
1525:
1526:            final PyObject long___pos__() {
1527:                return Py.newLong(value);
1528:            }
1529:
1530:            public PyObject __abs__() {
1531:                return long___abs__();
1532:            }
1533:
1534:            final PyObject long___abs__() {
1535:                return Py.newLong(value.abs());
1536:            }
1537:
1538:            public PyObject __invert__() {
1539:                return long___invert__();
1540:            }
1541:
1542:            final PyObject long___invert__() {
1543:                return Py.newLong(value.not());
1544:            }
1545:
1546:            public PyObject __int__() {
1547:                return long___int__();
1548:            }
1549:
1550:            final PyObject long___int__() {
1551:                long v = value.longValue();
1552:                if (v < Integer.MIN_VALUE || v > Integer.MAX_VALUE) {
1553:                    return Py.newLong(value);
1554:                }
1555:                return Py.newInteger((int) getLong(Integer.MIN_VALUE,
1556:                        Integer.MAX_VALUE));
1557:            }
1558:
1559:            public PyLong __long__() {
1560:                return long___long__();
1561:            }
1562:
1563:            final PyLong long___long__() {
1564:                return Py.newLong(value);
1565:            }
1566:
1567:            public PyFloat __float__() {
1568:                return long___float__();
1569:            }
1570:
1571:            final PyFloat long___float__() {
1572:                return new PyFloat(doubleValue());
1573:            }
1574:
1575:            public PyComplex __complex__() {
1576:                return long___complex__();
1577:            }
1578:
1579:            final PyComplex long___complex__() {
1580:                return new PyComplex(doubleValue(), 0.);
1581:            }
1582:
1583:            public PyString __oct__() {
1584:                return long___oct__();
1585:            }
1586:
1587:            final PyString long___oct__() {
1588:                String s = value.toString(8);
1589:                if (s.startsWith("-"))
1590:                    return new PyString("-0" + s.substring(1, s.length()) + "L");
1591:                else if (s.startsWith("0"))
1592:                    return new PyString(s + "L");
1593:                else
1594:                    return new PyString("0" + s + "L");
1595:            }
1596:
1597:            public PyString __hex__() {
1598:                return long___hex__();
1599:            }
1600:
1601:            final PyString long___hex__() {
1602:                String s = value.toString(16).toUpperCase();
1603:                if (s.startsWith("-"))
1604:                    return new PyString("-0x" + s.substring(1, s.length())
1605:                            + "L");
1606:                else
1607:                    return new PyString("0x" + s + "L");
1608:            }
1609:
1610:            public PyString __str__() {
1611:                return Py.newString(value.toString());
1612:            }
1613:
1614:            public PyUnicode __unicode__() {
1615:                return new PyUnicode(value.toString());
1616:            }
1617:
1618:            public boolean isMappingType() {
1619:                return false;
1620:            }
1621:
1622:            public boolean isSequenceType() {
1623:                return false;
1624:            }
1625:
1626:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.