123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>JSDoc: Source: bool.js</title>
- <script src="scripts/prettify/prettify.js"> </script>
- <script src="scripts/prettify/lang-css.js"> </script>
- <!--[if lt IE 9]>
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
- <![endif]-->
- <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
- <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
- </head>
- <body>
- <div id="main">
- <h1 class="page-title">Source: bool.js</h1>
-
-
- <section>
- <article>
- <pre class="prettyprint source linenums"><code>/**
- * @constructor
- * Sk.builtin.bool
- *
- * @description
- * Constructor for Python bool. Also used for builtin bool() function.
- *
- * Where possible, do not create a new instance but use the constants
- * Sk.builtin.bool.true$ or Sk.builtin.bool.false$. These are defined in src/constant.js
- *
- * @extends {Sk.builtin.object}
- *
- * @param {(Object|number|boolean)} x Value to evaluate as true or false
- * @return {Sk.builtin.bool} Sk.builtin.bool.true$ if x is true, Sk.builtin.bool.false$ otherwise
- */
- Sk.builtin.bool = function (x) {
- Sk.builtin.pyCheckArgs("bool", arguments, 1);
- if (Sk.misceval.isTrue(x)) {
- return Sk.builtin.bool.true$;
- } else {
- return Sk.builtin.bool.false$;
- }
- };
- Sk.abstr.setUpInheritance("bool", Sk.builtin.bool, Sk.builtin.int_);
- Sk.builtin.bool.prototype["$r"] = function () {
- if (this.v) {
- return new Sk.builtin.str("True");
- }
- return new Sk.builtin.str("False");
- };
- Sk.builtin.bool.prototype.tp$hash = function () {
- return new Sk.builtin.int_(this.v);
- };
- Sk.builtin.bool.prototype.__int__ = new Sk.builtin.func(function(self) {
- var v = Sk.builtin.asnum$(self);
- return new Sk.builtin.int_(v);
- });
- Sk.builtin.bool.prototype.__float__ = new Sk.builtin.func(function(self) {
- return new Sk.builtin.float_(Sk.ffi.remapToJs(self));
- });
- goog.exportSymbol("Sk.builtin.bool", Sk.builtin.bool);
- </code></pre>
- </article>
- </section>
- </div>
- <nav>
- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Sk.abstr.iter-seqIter.html">seqIter</a></li><li><a href="Sk.builtin.bool.html">bool</a></li><li><a href="Sk.builtin.float_.html">float_</a></li><li><a href="Sk.builtin.func.html">func</a></li><li><a href="Sk.builtin.int_.html">int_</a></li><li><a href="Sk.builtin.none.html">none</a></li><li><a href="Sk.builtin.NotImplemented.html">NotImplemented</a></li><li><a href="Sk.builtin.numtype.html">numtype</a></li><li><a href="Sk.builtin.object.html">object</a></li><li><a href="Sk.builtin.seqtype.html">seqtype</a></li><li><a href="Sk.misceval.Suspension.html">Suspension</a></li></ul><h3>Namespaces</h3><ul><li><a href="Sk.html">Sk</a></li><li><a href="Sk.abstr.html">abstr</a></li><li><a href="Sk.builtin.html">builtin</a></li><li><a href="Sk.ffi.html">ffi</a></li><li><a href="Sk.misceval.html">misceval</a></li></ul>
- </nav>
- <br class="clear">
- <footer>
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0</a> on Thu Aug 13 2015 08:14:27 GMT-0500 (CDT)
- </footer>
- <script> prettyPrint(); </script>
- <script src="scripts/linenumber.js"> </script>
- </body>
- </html>
|