Added additional MSP helper functions

10.3.x-maintenance
Anton Stålheim 2016-08-16 15:37:02 +02:00
parent abaf226818
commit 7c9261de8f
2 changed files with 300 additions and 401 deletions

View File

@ -10,3 +10,48 @@ Array.prototype.push16 = function(val) {
// chainable
return this;
};
DataView.prototype.offset = 0;
DataView.prototype.readU8 = function() {
if (this.byteLength >= this.offset+1) {
return this.getUint8(this.offset++);
} else {
return null;
}
}
DataView.prototype.readU16 = function() {
if (this.byteLength >= this.offset+2) {
return this.readU8() + this.readU8()*256;
} else {
return null;
}
}
DataView.prototype.readU32 = function() {
if (this.byteLength >= this.offset+4) {
return this.readU16() + this.readU16()*65536;
} else {
return null;
}
}
DataView.prototype.read8 = function() {
if (this.byteLength >= this.offset+1) {
return this.getInt8(this.offset++, 1);
} else {
return null;
}
}
DataView.prototype.read16 = function() {
this.offset += 2;
if (this.byteLength >= this.offset) {
return this.getInt16(this.offset-2, 1);
} else {
return null;
}
}
DataView.prototype.read32 = function() {
this.offset += 4;
if (this.byteLength >= this.offset) {
return this.getInt32(this.offset-4, 1);
} else {
return null;
}
}

File diff suppressed because it is too large Load Diff