From 26985f2813105aa5ed6a83c4a12011b8282f752a Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Tue, 12 Apr 2016 17:57:16 -0700 Subject: [PATCH 1/5] Default enum arguments not supported yet --- libs/microbit/music.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/microbit/music.ts b/libs/microbit/music.ts index 3bf0bfd2..1a7197e9 100644 --- a/libs/microbit/music.ts +++ b/libs/microbit/music.ts @@ -134,8 +134,9 @@ namespace music { */ //% help=music/beat weight=49 //% blockId=device_beat block="%fraction|beat" - export function beat(fraction : BeatFraction = BeatFraction.Whole): number { + export function beat(fraction?: BeatFraction): number { init(); + if (fraction == null) fraction = BeatFraction.Whole; let beat = 60000 / beatsPerMinute; if (fraction == BeatFraction.Whole) return beat; else if (fraction == BeatFraction.Half) return beat / 2; From df92a3daae49d934b0db3e837022a30941b99f95 Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Tue, 12 Apr 2016 18:51:56 -0700 Subject: [PATCH 2/5] Remove unused file --- libs/microbit/core.d.ts | 181 ---------------------------------------- 1 file changed, 181 deletions(-) delete mode 100644 libs/microbit/core.d.ts diff --git a/libs/microbit/core.d.ts b/libs/microbit/core.d.ts deleted file mode 100644 index 0f7f7f96..00000000 --- a/libs/microbit/core.d.ts +++ /dev/null @@ -1,181 +0,0 @@ -/// - -interface Array { - /** - * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. - */ - //% shim=Array_::length - length: number; - - /** - * Appends new elements to an array. - * @param items New elements of the Array. - */ - //% shim=Array_::push - push(item: T): void; - - /** - * Removes the last element from an array and returns it. - */ - //% helper=arrayPop - pop(): T; - - /** - * Reverses the elements in an Array. - */ - //% helper=arrayReverse - reverse(): void; - - /** - * Removes the first element from an array and returns it. - */ - //% helper=arrayShift - shift(): T; - - /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ - //% helper=arraySlice - slice(start: number, end: number): T[]; - - /** Removes the first occurence of an object. Returns true if removed. */ - //% shim=Array_::removeElement - removeElement(element:T) : boolean; - - /** Removes the object at position index. */ - //% shim=Array_::removeAt - removeAt(idx:number) : void; - - - /** - * Removes elements from an array. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - */ - //% helper=arraySplice - splice(start: number, deleteCount: number): void; - - /** - * Inserts new elements at the start of an array. - * @param items Elements to insert at the start of the Array. - */ - //% helper=arrayUnshift - unshift(item:T): void; - - /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. - */ - //% shim=Array_::indexOf - indexOf(searchElement: T, fromIndex?: number): number; - - - [n: number]: T; -} - -declare interface String { - /** - * Returns the character at the specified index. - * @param pos The zero-based index of the desired character. - */ - //% shim=String_::charAt - charAt(pos: number): string; - - /** - * Returns the Unicode value of the character at the specified location. - * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. - */ - //% shim=String_::charCodeAt - charCodeAt(index: number): number; - - /** - * Returns a string that contains the concatenation of two or more strings. - * @param other The string to append to the end of the string. - */ - //% shim=String_::concat - concat(other: string): string; - - /** - * Determines whether relative order of two strings (in ASCII encoding). - * @param that String to compare to target string - */ - //% shim=String_::compare - compare(that: string): number; - - /** Returns the length of a String object. */ - //% property shim=String_::length - length: number; - - [index: number]: string; -} - - - -/** - * Converts A string to an integer. - * @param s A string to convert into a number. - */ -//% shim=String_::toNumber -declare function parseInt(s: string): number; - -interface Object {} -interface Function {} -interface IArguments {} -interface RegExp {} - - -declare interface Boolean { - /** - * Returns a string representation of an object. - */ - //% shim=Boolean_::toString - toString(): string; -} - -declare namespace String { - - /** - * Make a string from the given ASCII character code. - */ - //% shim=String_::fromCharCode - function fromCharCode(code: number): string; -} - - -declare interface Number { - /** - * Returns a string representation of a number. - */ - //% shim=Number_::toString - toString(): string; -} - -/** - * Numbers and arithmetic operators - */ -declare namespace Math { - - /** - * Returns the value of a base expression taken to a specified power. - * @param x The base value of the expression. - * @param y The exponent value of the expression. - */ - //% shim=Math_::pow - function pow(x: number, y: number): number; - - /** - * Returns a pseudorandom number between 0 and `max`. - */ - //% shim=Math_::random - function random(max: number): number; - - /** - * Returns the square root of a number. - * @param x A numeric expression. - */ - //% shim=Math_::sqrt - function sqrt(x: number): number; -} From a0a0554633633ba5048b653c8e029a1ccec463cf Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Tue, 12 Apr 2016 19:08:26 -0700 Subject: [PATCH 3/5] Add String.substr --- libs/microbit/core.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/microbit/core.cpp b/libs/microbit/core.cpp index daccdd7d..e9ec6f82 100644 --- a/libs/microbit/core.cpp +++ b/libs/microbit/core.cpp @@ -42,6 +42,18 @@ namespace String_ { { return ManagedString::EmptyString.leakData(); } + + //% + StringData *substr(StringData *s, int start, int length) + { + if (length <= 0) + return mkEmpty(); + if (start < 0) + start = max(s->len + start, 0); + length = min(length, s->len - start); + ManagedString x(s); + return x.substring(start, length).leakData(); + } } From fddb9ff0d897d87186e2470d47be49c241b3d91f Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Tue, 12 Apr 2016 19:08:39 -0700 Subject: [PATCH 4/5] Bump pxt-core to 0.2.64 --- package.json | 64 ++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index e2fdb4c1..48dc340f 100644 --- a/package.json +++ b/package.json @@ -1,34 +1,34 @@ { - "name": "pxt-microbit", - "version": "0.2.60", - "description": "BBC micro:bit target for PXT", - "keywords": [ - "JavaScript", - "education", - "microbit" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/Microsoft/pxt-microbit.git" - }, - "author": "", - "license": "MIT", - "homepage": "https://github.com/Microsoft/pxt-microbit#readme", - "files": [ - "README.md", - "pxtarget.json", - "built/*.js", - "built/*.json", - "built/*.d.ts", - "sim/public", - "docs/*.md", - "docs/*/*.md", - "docs/*/*/*.md" - ], - "devDependencies": { - "typescript": "^1.8.7" - }, - "dependencies": { - "pxt-core": "0.2.62" - } + "name": "pxt-microbit", + "version": "0.2.60", + "description": "BBC micro:bit target for PXT", + "keywords": [ + "JavaScript", + "education", + "microbit" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/Microsoft/pxt-microbit.git" + }, + "author": "", + "license": "MIT", + "homepage": "https://github.com/Microsoft/pxt-microbit#readme", + "files": [ + "README.md", + "pxtarget.json", + "built/*.js", + "built/*.json", + "built/*.d.ts", + "sim/public", + "docs/*.md", + "docs/*/*.md", + "docs/*/*/*.md" + ], + "devDependencies": { + "typescript": "^1.8.7" + }, + "dependencies": { + "pxt-core": "0.2.64" + } } From 5e10bd7cc9f0b05baf732a7b45f2d971ff041dfc Mon Sep 17 00:00:00 2001 From: Michal Moskal Date: Tue, 12 Apr 2016 19:08:41 -0700 Subject: [PATCH 5/5] 0.2.61 --- package.json | 64 ++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 48dc340f..524a1bfc 100644 --- a/package.json +++ b/package.json @@ -1,34 +1,34 @@ { - "name": "pxt-microbit", - "version": "0.2.60", - "description": "BBC micro:bit target for PXT", - "keywords": [ - "JavaScript", - "education", - "microbit" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/Microsoft/pxt-microbit.git" - }, - "author": "", - "license": "MIT", - "homepage": "https://github.com/Microsoft/pxt-microbit#readme", - "files": [ - "README.md", - "pxtarget.json", - "built/*.js", - "built/*.json", - "built/*.d.ts", - "sim/public", - "docs/*.md", - "docs/*/*.md", - "docs/*/*/*.md" - ], - "devDependencies": { - "typescript": "^1.8.7" - }, - "dependencies": { - "pxt-core": "0.2.64" - } + "name": "pxt-microbit", + "version": "0.2.61", + "description": "BBC micro:bit target for PXT", + "keywords": [ + "JavaScript", + "education", + "microbit" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/Microsoft/pxt-microbit.git" + }, + "author": "", + "license": "MIT", + "homepage": "https://github.com/Microsoft/pxt-microbit#readme", + "files": [ + "README.md", + "pxtarget.json", + "built/*.js", + "built/*.json", + "built/*.d.ts", + "sim/public", + "docs/*.md", + "docs/*/*.md", + "docs/*/*/*.md" + ], + "devDependencies": { + "typescript": "^1.8.7" + }, + "dependencies": { + "pxt-core": "0.2.64" + } }