Source: numtype.js

  1. /**
  2. * @constructor
  3. * Sk.builtin.numtype
  4. *
  5. * @description
  6. * Abstract class for Python numeric types.
  7. *
  8. * @extends {Sk.builtin.object}
  9. *
  10. * @return {undefined} Cannot instantiate a Sk.builtin.numtype object
  11. */
  12. Sk.builtin.numtype = function () {
  13. throw new Sk.builtin.ExternalError("Cannot instantiate abstract Sk.builtin.numtype class");
  14. };
  15. Sk.abstr.setUpInheritance("NumericType", Sk.builtin.numtype, Sk.builtin.object);
  16. Sk.builtin.numtype.sk$abstract = true;
  17. /**
  18. * Python wrapper of `__abs__` method.
  19. *
  20. * @name __abs__
  21. * @instance
  22. * @memberOf Sk.builtin.numtype.prototype
  23. */
  24. Sk.builtin.numtype.prototype["__abs__"] = new Sk.builtin.func(function (self) {
  25. if (self.nb$abs === undefined) {
  26. throw new Sk.builtin.NotImplementedError("__abs__ is not yet implemented");
  27. }
  28. Sk.builtin.pyCheckArgsLen("__abs__", arguments.length, 0, 0, false, true);
  29. return self.nb$abs();
  30. });
  31. /**
  32. * Python wrapper of `__neg__` method.
  33. *
  34. * @name __neg__
  35. * @instance
  36. * @memberOf Sk.builtin.numtype.prototype
  37. */
  38. Sk.builtin.numtype.prototype["__neg__"] = new Sk.builtin.func(function (self) {
  39. if (self.nb$negative === undefined) {
  40. throw new Sk.builtin.NotImplementedError("__neg__ is not yet implemented");
  41. }
  42. Sk.builtin.pyCheckArgsLen("__neg__", arguments.length, 0, 0, false, true);
  43. return self.nb$negative();
  44. });
  45. /**
  46. * Python wrapper of `__pos__` method.
  47. *
  48. * @name __pos__
  49. * @instance
  50. * @memberOf Sk.builtin.numtype.prototype
  51. */
  52. Sk.builtin.numtype.prototype["__pos__"] = new Sk.builtin.func(function (self) {
  53. if (self.nb$positive === undefined) {
  54. throw new Sk.builtin.NotImplementedError("__pos__ is not yet implemented");
  55. }
  56. Sk.builtin.pyCheckArgsLen("__pos__", arguments.length, 0, 0, false, true);
  57. return self.nb$positive();
  58. });
  59. /**
  60. * Python wrapper of `__int__` method.
  61. *
  62. * @name __int__
  63. * @instance
  64. * @memberOf Sk.builtin.numtype.prototype
  65. */
  66. Sk.builtin.numtype.prototype["__int__"] = new Sk.builtin.func(function (self) {
  67. if (self.nb$int_ === undefined) {
  68. throw new Sk.builtin.NotImplementedError("__int__ is not yet implemented");
  69. }
  70. Sk.builtin.pyCheckArgsLen("__int__", arguments.length, 0, 0, false, true);
  71. return self.nb$int_();
  72. });
  73. /**
  74. * Python wrapper of `__long__` method.
  75. *
  76. * @name __long__
  77. * @instance
  78. * @memberOf Sk.builtin.numtype.prototype
  79. */
  80. Sk.builtin.numtype.prototype["__long__"] = new Sk.builtin.func(function (self) {
  81. if (self.nb$lng === undefined) {
  82. throw new Sk.builtin.NotImplementedError("__long__ is not yet implemented");
  83. }
  84. Sk.builtin.pyCheckArgsLen("__long__", arguments.length, 0, 0, false, true);
  85. return self.nb$lng();
  86. });
  87. /**
  88. * Python wrapper of `__float__` method.
  89. *
  90. * @name __float__
  91. * @instance
  92. * @memberOf Sk.builtin.numtype.prototype
  93. */
  94. Sk.builtin.numtype.prototype["__float__"] = new Sk.builtin.func(function (self) {
  95. if (self.nb$float_ === undefined) {
  96. throw new Sk.builtin.NotImplementedError("__float__ is not yet implemented");
  97. }
  98. Sk.builtin.pyCheckArgsLen("__float__", arguments.length, 0, 0, false, true);
  99. return self.nb$float_();
  100. });
  101. /**
  102. * Python wrapper of `__add__` method.
  103. *
  104. * @name __add__
  105. * @instance
  106. * @memberOf Sk.builtin.numtype.prototype
  107. */
  108. Sk.builtin.numtype.prototype["__add__"] = new Sk.builtin.func(function (self, other) {
  109. if (self.nb$add === undefined) {
  110. throw new Sk.builtin.NotImplementedError("__add__ is not yet implemented");
  111. }
  112. Sk.builtin.pyCheckArgsLen("__add__", arguments.length, 1, 1, false, true);
  113. return self.nb$add(other);
  114. });
  115. /**
  116. * Python wrapper of `__radd__` method.
  117. *
  118. * @name __radd__
  119. * @instance
  120. * @memberOf Sk.builtin.numtype.prototype
  121. */
  122. Sk.builtin.numtype.prototype["__radd__"] = new Sk.builtin.func(function (self, other) {
  123. if (self.nb$reflected_add === undefined) {
  124. throw new Sk.builtin.NotImplementedError("__radd__ is not yet implemented");
  125. }
  126. Sk.builtin.pyCheckArgsLen("__radd__", arguments.length, 1, 1, false, true);
  127. return self.nb$reflected_add(other);
  128. });
  129. /**
  130. * Python wrapper of `__sub__` method.
  131. *
  132. * @name __sub__
  133. * @instance
  134. * @memberOf Sk.builtin.numtype.prototype
  135. */
  136. Sk.builtin.numtype.prototype["__sub__"] = new Sk.builtin.func(function (self, other) {
  137. if (self.nb$subtract === undefined) {
  138. throw new Sk.builtin.NotImplementedError("__sub__ is not yet implemented");
  139. }
  140. Sk.builtin.pyCheckArgsLen("__sub__", arguments.length, 1, 1, false, true);
  141. return self.nb$subtract(other);
  142. });
  143. /**
  144. * Python wrapper of `__rsub__` method.
  145. *
  146. * @name __rsub__
  147. * @instance
  148. * @memberOf Sk.builtin.numtype.prototype
  149. */
  150. Sk.builtin.numtype.prototype["__rsub__"] = new Sk.builtin.func(function (self, other) {
  151. if (self.nb$reflected_subtract === undefined) {
  152. throw new Sk.builtin.NotImplementedError("__rsub__ is not yet implemented");
  153. }
  154. Sk.builtin.pyCheckArgsLen("__rsub__", arguments.length, 1, 1, false, true);
  155. return self.nb$reflected_subtract(other);
  156. });
  157. /**
  158. * Python wrapper of `__mul__` method.
  159. *
  160. * @name __mul__
  161. * @instance
  162. * @memberOf Sk.builtin.numtype.prototype
  163. */
  164. Sk.builtin.numtype.prototype["__mul__"] = new Sk.builtin.func(function (self, other) {
  165. if (self.nb$multiply === undefined) {
  166. throw new Sk.builtin.NotImplementedError("__mul__ is not yet implemented");
  167. }
  168. Sk.builtin.pyCheckArgsLen("__mul__", arguments.length, 1, 1, false, true);
  169. return self.nb$multiply(other);
  170. });
  171. /**
  172. * Python wrapper of `__rmul__` method.
  173. *
  174. * @name __rmul__
  175. * @instance
  176. * @memberOf Sk.builtin.numtype.prototype
  177. */
  178. Sk.builtin.numtype.prototype["__rmul__"] = new Sk.builtin.func(function (self, other) {
  179. if (self.nb$reflected_multiply === undefined) {
  180. throw new Sk.builtin.NotImplementedError("__rmul__ is not yet implemented");
  181. }
  182. Sk.builtin.pyCheckArgsLen("__rmul__", arguments.length, 1, 1, false, true);
  183. return self.nb$reflected_multiply(other);
  184. });
  185. /**
  186. * Python wrapper of `__div__` method.
  187. *
  188. * @name __div__
  189. * @instance
  190. * @memberOf Sk.builtin.numtype.prototype
  191. */
  192. Sk.builtin.numtype.prototype["__div__"] = new Sk.builtin.func(function (self, other) {
  193. if (self.nb$divide === undefined) {
  194. throw new Sk.builtin.NotImplementedError("__div__ is not yet implemented");
  195. }
  196. Sk.builtin.pyCheckArgsLen("__div__", arguments.length, 1, 1, false, true);
  197. return self.nb$divide(other);
  198. });
  199. /**
  200. * Python wrapper of `__rdiv__` method.
  201. *
  202. * @name __rdiv__
  203. * @instance
  204. * @memberOf Sk.builtin.numtype.prototype
  205. */
  206. Sk.builtin.numtype.prototype["__rdiv__"] = new Sk.builtin.func(function (self, other) {
  207. if (self.nb$reflected_divide === undefined) {
  208. throw new Sk.builtin.NotImplementedError("__rdiv__ is not yet implemented");
  209. }
  210. Sk.builtin.pyCheckArgsLen("__rdiv__", arguments.length, 1, 1, false, true);
  211. return self.nb$reflected_divide(other);
  212. });
  213. /**
  214. * Python wrapper of `__floordiv__` method.
  215. *
  216. * @name __floordiv__
  217. * @instance
  218. * @memberOf Sk.builtin.numtype.prototype
  219. */
  220. Sk.builtin.numtype.prototype["__floordiv__"] = new Sk.builtin.func(function (self, other) {
  221. if (self.nb$floor_divide === undefined) {
  222. throw new Sk.builtin.NotImplementedError("__floordiv__ is not yet implemented");
  223. }
  224. Sk.builtin.pyCheckArgsLen("__floordiv__", arguments.length, 1, 1, false, true);
  225. return self.nb$floor_divide(other);
  226. });
  227. /**
  228. * Python wrapper of `__rfloordiv__` method.
  229. *
  230. * @name __rfloordiv__
  231. * @instance
  232. * @memberOf Sk.builtin.numtype.prototype
  233. */
  234. Sk.builtin.numtype.prototype["__rfloordiv__"] = new Sk.builtin.func(function (self, other) {
  235. if (self.nb$reflected_floor_divide === undefined) {
  236. throw new Sk.builtin.NotImplementedError("__rfloordiv__ is not yet implemented");
  237. }
  238. Sk.builtin.pyCheckArgsLen("__rfloordiv__", arguments.length, 1, 1, false, true);
  239. return self.nb$reflected_floor_divide(other);
  240. });
  241. /**
  242. * Python wrapper of `__mod__` method.
  243. *
  244. * @name __mod__
  245. * @instance
  246. * @memberOf Sk.builtin.numtype.prototype
  247. */
  248. Sk.builtin.numtype.prototype["__mod__"] = new Sk.builtin.func(function (self, other) {
  249. if (self.nb$remainder === undefined) {
  250. throw new Sk.builtin.NotImplementedError("__mod__ is not yet implemented");
  251. }
  252. Sk.builtin.pyCheckArgsLen("__mod__", arguments.length, 1, 1, false, true);
  253. return self.nb$remainder(other);
  254. });
  255. /**
  256. * Python wrapper of `__rmod__` method.
  257. *
  258. * @name __rmod__
  259. * @instance
  260. * @memberOf Sk.builtin.numtype.prototype
  261. */
  262. Sk.builtin.numtype.prototype["__rmod__"] = new Sk.builtin.func(function (self, other) {
  263. if (self.nb$reflected_remainder === undefined) {
  264. throw new Sk.builtin.NotImplementedError("__rmod__ is not yet implemented");
  265. }
  266. Sk.builtin.pyCheckArgsLen("__rmod__", arguments.length, 1, 1, false, true);
  267. return self.nb$reflected_remainder(other);
  268. });
  269. /**
  270. * Python wrapper of `__divmod__` method.
  271. *
  272. * @name __divmod__
  273. * @instance
  274. * @memberOf Sk.builtin.numtype.prototype
  275. */
  276. Sk.builtin.numtype.prototype["__divmod__"] = new Sk.builtin.func(function (self, other) {
  277. if (self.nb$divmod === undefined) {
  278. throw new Sk.builtin.NotImplementedError("__divmod__ is not yet implemented");
  279. }
  280. Sk.builtin.pyCheckArgsLen("__divmod__", arguments.length, 1, 1, false, true);
  281. return self.nb$divmod(other);
  282. });
  283. /**
  284. * Python wrapper of `__rdivmod__` method.
  285. *
  286. * @name __rdivmod__
  287. * @instance
  288. * @memberOf Sk.builtin.numtype.prototype
  289. */
  290. Sk.builtin.numtype.prototype["__rdivmod__"] = new Sk.builtin.func(function (self, other) {
  291. if (self.nb$reflected_divmod === undefined) {
  292. throw new Sk.builtin.NotImplementedError("__rdivmod__ is not yet implemented");
  293. }
  294. Sk.builtin.pyCheckArgsLen("__rdivmod__", arguments.length, 1, 1, false, true);
  295. return self.nb$reflected_divmod(other);
  296. });
  297. /**
  298. * Python wrapper of `__pow__` method.
  299. *
  300. * @name __pow__
  301. * @instance
  302. * @memberOf Sk.builtin.numtype.prototype
  303. */
  304. Sk.builtin.numtype.prototype["__pow__"] = new Sk.builtin.func(function (self, other) {
  305. if (self.nb$power === undefined) {
  306. throw new Sk.builtin.NotImplementedError("__pow__ is not yet implemented");
  307. }
  308. Sk.builtin.pyCheckArgsLen("__pow__", arguments.length, 1, 1, false, true);
  309. return self.nb$power(other);
  310. });
  311. /**
  312. * Python wrapper of `__rpow__` method.
  313. *
  314. * @name __rpow__
  315. * @instance
  316. * @memberOf Sk.builtin.numtype.prototype
  317. */
  318. Sk.builtin.numtype.prototype["__rpow__"] = new Sk.builtin.func(function (self, other) {
  319. if (self.nb$reflected_power === undefined) {
  320. throw new Sk.builtin.NotImplementedError("__rpow__ is not yet implemented");
  321. }
  322. Sk.builtin.pyCheckArgsLen("__rpow__", arguments.length, 1, 1, false, true);
  323. return self.nb$reflected_power(other);
  324. });
  325. /**
  326. * Python wrapper of `__coerce__` method.
  327. *
  328. * @name __coerce__
  329. * @instance
  330. * @memberOf Sk.builtin.numtype.prototype
  331. */
  332. Sk.builtin.numtype.prototype["__coerce__"] = new Sk.builtin.func(function (self, other) {
  333. throw new Sk.builtin.NotImplementedError("__coerce__ is not yet implemented");
  334. });
  335. /**
  336. * Add a Python object to this instance and return the result (i.e. this + other).
  337. *
  338. * Returns NotImplemented if addition between this type and other type is unsupported.
  339. *
  340. * Javscript function, returns Python object.
  341. *
  342. * @param {!Sk.builtin.object} other The Python object to add.
  343. * @return {(Sk.builtin.numtype|Sk.builtin.NotImplemented)} The result of the addition.
  344. */
  345. Sk.builtin.numtype.prototype.nb$add = function (other) {
  346. return Sk.builtin.NotImplemented.NotImplemented$;
  347. };
  348. Sk.builtin.numtype.prototype.nb$reflected_add = function (other) {
  349. return Sk.builtin.NotImplemented.NotImplemented$;
  350. };
  351. Sk.builtin.numtype.prototype.nb$inplace_add = function (other) {
  352. return Sk.builtin.NotImplemented.NotImplemented$;
  353. };
  354. /**
  355. * Subtract a Python object from this instance and return the result (i.e. this - other).
  356. *
  357. * Returns NotImplemented if subtraction between this type and other type is unsupported.
  358. *
  359. * Javscript function, returns Python object.
  360. *
  361. * @param {!Sk.builtin.object} other The Python object to subtract.
  362. * @return {(Sk.builtin.numtype|Sk.builtin.NotImplemented)} The result of the subtraction.
  363. */
  364. Sk.builtin.numtype.prototype.nb$subtract = function (other) {
  365. return Sk.builtin.NotImplemented.NotImplemented$;
  366. };
  367. Sk.builtin.numtype.prototype.nb$reflected_subtract = function (other) {
  368. return Sk.builtin.NotImplemented.NotImplemented$;
  369. };
  370. Sk.builtin.numtype.prototype.nb$inplace_subtract = function (other) {
  371. return Sk.builtin.NotImplemented.NotImplemented$;
  372. };
  373. /**
  374. * Multiply this instance by a Python object and return the result (i.e. this * other).
  375. *
  376. * Returns NotImplemented if multiplication between this type and other type is unsupported.
  377. *
  378. * Javscript function, returns Python object.
  379. *
  380. * @param {!Sk.builtin.object} other The multiplier, which must be a Python object.
  381. * @return {(Sk.builtin.numtype|Sk.builtin.NotImplemented)} The result of the multiplication
  382. */
  383. Sk.builtin.numtype.prototype.nb$multiply = function (other) {
  384. return Sk.builtin.NotImplemented.NotImplemented$;
  385. };
  386. Sk.builtin.numtype.prototype.nb$reflected_multiply = function (other) {
  387. return Sk.builtin.NotImplemented.NotImplemented$;
  388. };
  389. Sk.builtin.numtype.prototype.nb$inplace_multiply = function (other) {
  390. return Sk.builtin.NotImplemented.NotImplemented$;
  391. };
  392. /**
  393. * Divide this instance by a Python object and return the result (i.e this / other).
  394. *
  395. * Returns NotImplemented if division between this type and other type is unsupported.
  396. *
  397. * Javscript function, returns Python object.
  398. *
  399. * @param {!Sk.builtin.object} other The divisor, which must be a Python object.
  400. * @return {(Sk.builtin.numtype|Sk.builtin.NotImplemented)} The result of the division
  401. */
  402. Sk.builtin.numtype.prototype.nb$divide = function (other) {
  403. return Sk.builtin.NotImplemented.NotImplemented$;
  404. };
  405. Sk.builtin.numtype.prototype.nb$reflected_divide = function (other) {
  406. return Sk.builtin.NotImplemented.NotImplemented$;
  407. };
  408. Sk.builtin.numtype.prototype.nb$inplace_divide = function (other) {
  409. return Sk.builtin.NotImplemented.NotImplemented$;
  410. };
  411. /**
  412. * Floor divide this instance by a Python object and return the result (i.e. this // other).
  413. *
  414. * Returns NotImplemented if floor division between this type and other type is unsupported.
  415. *
  416. * Javscript function, returns Python object.
  417. *
  418. * @param {!Sk.builtin.object} other The divisor, which must be a Python object.
  419. * @return {(Sk.builtin.numtype|Sk.builtin.NotImplemented)} The result of the floor division
  420. */
  421. Sk.builtin.numtype.prototype.nb$floor_divide = function (other) {
  422. return Sk.builtin.NotImplemented.NotImplemented$;
  423. };
  424. Sk.builtin.numtype.prototype.nb$reflected_floor_divide = function (other) {
  425. return Sk.builtin.NotImplemented.NotImplemented$;
  426. };
  427. Sk.builtin.numtype.prototype.nb$inplace_floor_divide = function (other) {
  428. return Sk.builtin.NotImplemented.NotImplemented$;
  429. };
  430. /**
  431. * Modulo this instance by a Python object and return the result (i.e. this % other).
  432. *
  433. * Returns NotImplemented if modulation between this type and other type is unsupported.
  434. *
  435. * Javscript function, returns Python object.
  436. *
  437. * @param {!Sk.builtin.object} other The divisor, which must be a Python object.
  438. * @return {(Sk.builtin.numtype|Sk.builtin.NotImplemented)} The result of the modulation
  439. */
  440. Sk.builtin.numtype.prototype.nb$remainder = function (other) {
  441. return Sk.builtin.NotImplemented.NotImplemented$;
  442. };
  443. Sk.builtin.numtype.prototype.nb$reflected_remainder = function (other) {
  444. return Sk.builtin.NotImplemented.NotImplemented$;
  445. };
  446. Sk.builtin.numtype.prototype.nb$inplace_remainder = function (other) {
  447. return Sk.builtin.NotImplemented.NotImplemented$;
  448. };
  449. /**
  450. * Compute the quotient and the remainder of this instance and a given Python object and return the result.
  451. *
  452. * Returns NotImplemented if division or modulo operations between this type and other type are unsupported.
  453. *
  454. * Javscript function, returns Python object.
  455. *
  456. * @param {!Sk.builtin.object} other The divisor, which must be a Python object.
  457. * @return {(Sk.builtin.tuple|Sk.builtin.NotImplemented)} The result of the operation.
  458. * If both operations are supported, a Python tuple containing (quotient, remainder) in that order.
  459. */
  460. Sk.builtin.numtype.prototype.nb$divmod = function (other) {
  461. return Sk.builtin.NotImplemented.NotImplemented$;
  462. };
  463. Sk.builtin.numtype.prototype.nb$reflected_divmod = function (other) {
  464. return Sk.builtin.NotImplemented.NotImplemented$;
  465. };
  466. /**
  467. * Raise this instance by a Python object, optionally modulo the exponent, and return the final result.
  468. *
  469. * If mod is undefined, return this \*\* other. Else, return (this \*\* other) % mod.
  470. *
  471. * Returns NotImplemented if exponentiation or modulation between this type and other type is unsupported.
  472. *
  473. * Javscript function, returns Python object.
  474. *
  475. * @param {!Sk.builtin.object} other The exponent, which must be a Python object.
  476. * @param {!Sk.builtin.object=} mod The optional divisor, which must be a Python object if defined.
  477. * @return {(Sk.builtin.numtype|Sk.builtin.NotImplemented)} The result of the exponentiation.
  478. */
  479. Sk.builtin.numtype.prototype.nb$power = function (other, mod) {
  480. return Sk.builtin.NotImplemented.NotImplemented$;
  481. };
  482. Sk.builtin.numtype.prototype.nb$reflected_power = function (other, mod) {
  483. return Sk.builtin.NotImplemented.NotImplemented$;
  484. };
  485. Sk.builtin.numtype.prototype.nb$inplace_power = function (other) {
  486. return Sk.builtin.NotImplemented.NotImplemented$;
  487. };
  488. /**
  489. * Compute the absolute value of this instance and return.
  490. *
  491. * Javascript function, returns Python object.
  492. *
  493. * @return {(Sk.builtin.numtype|Sk.builtin.NotImplemented)} The absolute value
  494. */
  495. Sk.builtin.numtype.prototype.nb$abs = function () {
  496. return Sk.builtin.NotImplemented.NotImplemented$;
  497. };
  498. /**
  499. * Compute the unary negative of this instance (i.e. -this).
  500. *
  501. * Javscript function, returns Python object.
  502. *
  503. * @return {(Sk.builtin.numtype|Sk.builtin.NotImplemented)} A copy of this instance with the value negated
  504. */
  505. Sk.builtin.numtype.prototype.nb$negative = function () {
  506. return Sk.builtin.NotImplemented.NotImplemented$;
  507. };
  508. /**
  509. * Compute the unary positive of this instance (i.e. +this).
  510. *
  511. * Javscript function, returns Python object.
  512. *
  513. * @return {(Sk.builtin.numtype|Sk.builtin.NotImplemented)} A copy of this instance with the value unchanged
  514. */
  515. Sk.builtin.numtype.prototype.nb$positive = function () {
  516. return Sk.builtin.NotImplemented.NotImplemented$;
  517. };
  518. /**
  519. * Determine if this instance is nonzero.
  520. *
  521. * Javscript function, returns Javascript object or Sk.builtin.NotImplemented.
  522. *
  523. * @return {(boolean|Sk.builtin.NotImplemented)} true if this instance is not equal to zero, false otherwise
  524. */
  525. Sk.builtin.numtype.prototype.nb$nonzero = function () {
  526. return Sk.builtin.NotImplemented.NotImplemented$;
  527. };
  528. /**
  529. * Determine if this instance is negative.
  530. *
  531. * Javscript function, returns Javascript object or Sk.builtin.NotImplemented.
  532. *
  533. * @return {(boolean|Sk.builtin.NotImplemented)} true if this instance is negative, false otherwise
  534. */
  535. Sk.builtin.numtype.prototype.nb$isnegative = function () {
  536. return Sk.builtin.NotImplemented.NotImplemented$;
  537. };
  538. /**
  539. * Determine if this instance is positive.
  540. *
  541. * Javscript function, returns Javascript object or Sk.builtin.NotImplemented.
  542. *
  543. * @return {(boolean|Sk.builtin.NotImplemented)} true if this instance is positive, false otherwise
  544. */
  545. Sk.builtin.numtype.prototype.nb$ispositive = function () {
  546. return Sk.builtin.NotImplemented.NotImplemented$;
  547. };