From f2c43c74acd66e3b63b2b1f8f51592ab868c771e Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 4 Aug 2016 08:42:47 -0700 Subject: [PATCH] support for start/length in buffer methods --- libs/microbit/buffer.cpp | 12 ++++++++---- libs/microbit/shims.d.ts | 12 ++++++++---- pxtarget.json | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/libs/microbit/buffer.cpp b/libs/microbit/buffer.cpp index 41634e0d..b0ea48a2 100644 --- a/libs/microbit/buffer.cpp +++ b/libs/microbit/buffer.cpp @@ -123,21 +123,25 @@ namespace BufferMethods { /** * Shift buffer left in place, with zero padding. * @param offset number of bytes to shift; use negative value to shift right + * @param start start offset in buffer. Default is 0. + * @param length number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1 */ //% - void shift(Buffer buf, int offset) + void shift(Buffer buf, int offset, int start = 0, int length = -1) { - ManagedBuffer(buf).shift(offset); + ManagedBuffer(buf).shift(offset, start, length); } /** * Rotate buffer left in place. * @param offset number of bytes to shift; use negative value to shift right + * @param start start offset in buffer. Default is 0. + * @param length number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1 */ //% - void rotate(Buffer buf, int offset) + void rotate(Buffer buf, int offset, int start = 0, int length = -1) { - ManagedBuffer(buf).rotate(offset); + ManagedBuffer(buf).rotate(offset, start, length); } // int readBytes(uint8_t *dst, int offset, int length, bool swapBytes = false) const; diff --git a/libs/microbit/shims.d.ts b/libs/microbit/shims.d.ts index 4974158a..99102c46 100644 --- a/libs/microbit/shims.d.ts +++ b/libs/microbit/shims.d.ts @@ -635,16 +635,20 @@ declare interface Buffer { /** * Shift buffer left in place, with zero padding. * @param offset number of bytes to shift; use negative value to shift right + * @param start start offset in buffer. Default is 0. + * @param length number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1 */ - //% shim=BufferMethods::shift - shift(offset: number): void; + //% start.defl=0 length.defl=-1 shim=BufferMethods::shift + shift(offset: number, start?: number, length?: number): void; /** * Rotate buffer left in place. * @param offset number of bytes to shift; use negative value to shift right + * @param start start offset in buffer. Default is 0. + * @param length number of elements in buffer. If negative, length is set as the buffer length minus start. eg: -1 */ - //% shim=BufferMethods::rotate - rotate(offset: number): void; + //% start.defl=0 length.defl=-1 shim=BufferMethods::rotate + rotate(offset: number, start?: number, length?: number): void; /** * Write contents of `src` at `dstOffset` in current buffer. diff --git a/pxtarget.json b/pxtarget.json index cbd3ab2b..d6f47755 100644 --- a/pxtarget.json +++ b/pxtarget.json @@ -70,7 +70,7 @@ "yottaTarget": "bbc-microbit-classic-gcc", "yottaCorePackage": "pxt-microbit-core", "githubCorePackage": "microsoft/pxt-microbit-core", - "gittag": "v0.1.11", + "gittag": "v0.2.2", "serviceId": "ws" }, "serial": {