pxt-common-packages 13.2.4 → 13.2.6

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.
@@ -46,6 +46,7 @@
46
46
 
47
47
  #include <string.h>
48
48
  #include <stdint.h>
49
+ #include <stddef.h> // offsetof
49
50
  #include <math.h>
50
51
 
51
52
  #ifdef POKY
@@ -552,7 +553,22 @@ class Segment {
552
553
  TValue get(unsigned i) { return i < length ? data[i] : NULL; }
553
554
  void set(unsigned i, TValue value);
554
555
 
555
- unsigned getLength() { return length; };
556
+ unsigned getLength() {
557
+ // Layout pinned for the PXT compiler's Array.length fast path
558
+ // (_pxt_array_length_tagged in pxt/pxtcompiler/emitter/backthumb.ts).
559
+ // That fast path reads the element count directly out of the array
560
+ // object at a fixed byte offset instead of calling Array_::length:
561
+ // array object[0] = RefObject.vtable
562
+ // array object[sizeof(void*)] = RefCollection.head (this Segment)
563
+ // head[sizeof(TValue*)] = Segment.length
564
+ // so the length lives at object offset 2*sizeof(void*) == 8 on the
565
+ // 32-bit thumb target, read there as `ldrh r0, [r0, #8]`. If these
566
+ // structs are reordered, the offset in backthumb.ts must change too;
567
+ // these asserts fail the native build if that ever drifts.
568
+ STATIC_ASSERT(sizeof(RefObject) == sizeof(void *));
569
+ STATIC_ASSERT(offsetof(Segment, length) == sizeof(TValue *));
570
+ return length;
571
+ };
556
572
  void setLength(unsigned newLength);
557
573
 
558
574
  void push(TValue value) { set(length, value); }
@@ -6,7 +6,7 @@ class SoundOutput {
6
6
  public:
7
7
  NRF52PWM dac;
8
8
 
9
- SoundOutput(DataSource &data) : dac(NRF_PWM0, data) {
9
+ SoundOutput(DataSource &data) : dac(NRF_PWM0, data, 44100) {
10
10
  dac.setDecoderMode( PWM_DECODER_LOAD_Common );
11
11
  dac.connectPin(*LOOKUP_PIN(JACK_SND), 0);
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pxt-common-packages",
3
- "version": "13.2.4",
3
+ "version": "13.2.6",
4
4
  "description": "Microsoft MakeCode (PXT) common packages",
5
5
  "keywords": [
6
6
  "MakeCode",