pxt-common-packages 12.0.2 → 12.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -428,7 +428,7 @@ var pxsim;
428
428
  (function (pxtcore) {
429
429
  // TODO: add in support for mode, as in CODAL
430
430
  function registerWithDal(id, evid, handler, mode = 0) {
431
- pxsim.board().bus.listen(id, evid, handler);
431
+ pxsim.board().bus.listen(id, evid, handler, mode);
432
432
  }
433
433
  pxtcore.registerWithDal = registerWithDal;
434
434
  function deepSleep() {
@@ -1338,8 +1338,27 @@ namespace Math_ {
1338
1338
  //%
1339
1339
  TNumber pow(TNumber x, TNumber y) {
1340
1340
  #ifdef PXT_POWI
1341
- // regular pow() from math.h is 4k of code
1342
- return fromDouble(__builtin_powi(toDouble(x), toInt(y)));
1341
+ // regular pow() from math.h is 4k of code, but it can
1342
+ // also be expressed as exp(y * log(x)) which is less
1343
+ // performant than pow() but doesn't increase code size
1344
+ double dx = toDouble(x);
1345
+ double dy = toDouble(y);
1346
+
1347
+ // shortcut to integer pow if y is an integer
1348
+ if (::floor(dy) == dy) {
1349
+ return fromDouble(__builtin_powi(dx, dy));
1350
+ }
1351
+ if (dx > 0) {
1352
+ return fromDouble(::exp(dy * ::log(dx)));
1353
+ }
1354
+ if (dx == 0) {
1355
+ if (dy < 0) {
1356
+ // positive infinity
1357
+ return fromDouble(HUGE_VAL);
1358
+ }
1359
+ return x;
1360
+ }
1361
+ return fromDouble(::log(dx));
1343
1362
  #else
1344
1363
  return fromDouble(::pow(toDouble(x), toDouble(y)));
1345
1364
  #endif
@@ -1,7 +1,7 @@
1
1
  namespace pxsim.pxtcore {
2
2
  // TODO: add in support for mode, as in CODAL
3
3
  export function registerWithDal(id: number, evid: number, handler: RefAction, mode: number = 0) {
4
- board().bus.listen(id, evid, handler);
4
+ board().bus.listen(id, evid, handler, mode);
5
5
  }
6
6
 
7
7
  export function deepSleep() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pxt-common-packages",
3
- "version": "12.0.2",
3
+ "version": "12.0.4",
4
4
  "description": "Microsoft MakeCode (PXT) common packages",
5
5
  "keywords": [
6
6
  "MakeCode",
@@ -24,7 +24,7 @@
24
24
  "libs/**/*"
25
25
  ],
26
26
  "dependencies": {
27
- "pxt-core": "10.0.3"
27
+ "pxt-core": "10.2.3"
28
28
  },
29
29
  "devDependencies": {
30
30
  "typescript": "^4.2.3"