Commit 56ec48be authored by Joel Martin's avatar Joel Martin

Move vars into RFB namespace. Extend array in util.js.

parent c4164bda
...@@ -27,3 +27,61 @@ function dirObj(obj, depth, parent) { ...@@ -27,3 +27,61 @@ function dirObj(obj, depth, parent) {
} }
return msg; return msg;
} }
/*
* Make arrays quack
*/
Array.prototype.shift8 = function () {
return this.shift();
};
Array.prototype.push8 = function (num) {
this.push(num & 0xFF);
};
Array.prototype.shift16 = function () {
return (this.shift() << 8) +
(this.shift() );
};
Array.prototype.push16 = function (num) {
this.push((num >> 8) & 0xFF,
(num ) & 0xFF );
};
Array.prototype.shift32 = function () {
return (this.shift() << 24) +
(this.shift() << 16) +
(this.shift() << 8) +
(this.shift() );
};
Array.prototype.get32 = function (off) {
return (this[off ] << 24) +
(this[off + 1] << 16) +
(this[off + 2] << 8) +
(this[off + 3] );
};
Array.prototype.push32 = function (num) {
this.push((num >> 24) & 0xFF,
(num >> 16) & 0xFF,
(num >> 8) & 0xFF,
(num ) & 0xFF );
};
Array.prototype.shiftStr = function (len) {
var arr = this.splice(0, len);
return arr.map(function (num) {
return String.fromCharCode(num); } ).join('');
};
Array.prototype.pushStr = function (str) {
var i, n = str.length;
for (i=0; i < n; i++) {
this.push(str.charCodeAt(i));
}
};
Array.prototype.shiftBytes = function (len) {
return this.splice(0, len);
};
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment