Skip to content

Commit

Permalink
Whitespace fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
cscott committed Jun 4, 2011
1 parent beb0a86 commit 47f9485
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 153 deletions.
20 changes: 10 additions & 10 deletions bcompile.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ define(["bytecode-table"], function make_bcompile(bytecode_table) {
// compact encoding
var encode_uint = function(out, val) {
assert(val >= 0, val);
if (val < 128) {
out.push(val);
return;
}
var msb = Math.floor(val / 128);
var lsb = (val - 128*msb);
if (val < 128) {
out.push(val);
return;
}
var msb = Math.floor(val / 128);
var lsb = (val - 128*msb);
assert(lsb >= 0 && lsb < 128, val);
assert(msb > 0, val);
// little-endian
out.push(lsb + 128);
encode_uint(out, msb);
// little-endian
out.push(lsb + 128);
encode_uint(out, msb);
};
var encode_str = function(out, str) {
var i = 0;
Expand All @@ -148,7 +148,7 @@ define(["bytecode-table"], function make_bcompile(bytecode_table) {
var j = 0;
while (j < f.bytecode.length) {
var v = f.bytecode[j];
v = (typeof(v) === "number") ? v : v.label;
v = (typeof(v) === "number") ? v : v.label;
encode_uint(out, v);
j += 1;
}
Expand Down
8 changes: 4 additions & 4 deletions binterp.js
Original file line number Diff line number Diff line change
Expand Up @@ -623,16 +623,16 @@ define(["bytecode-table", "!html-escape"], function make_binterp(bytecode_table,
}
return result;
};
Array.prototype.forEach = function(block, thisObject) {
Array.prototype.forEach = function(block, thisObject) {
var len = (1*this.length) || 0;
var i = 0;
while (i < len) {
if (this.hasOwnProperty(i)) {
block.call(thisObject, this[i], i, this);
}
i += 1;
}
i += 1;
}
};
};
Array.prototype.map = function(fun /*, thisp*/) {
var len = (1*this.length) || 0;
/*
Expand Down
6 changes: 3 additions & 3 deletions bytecode-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ define(function make_bytecode_table() {

// OK, return an object wrapping all this stuff.
return {
__module_name__: "bytecode-table",
__module_init__: make_bytecode_table,
__module_deps__: [],
__module_name__: "bytecode-table",
__module_init__: make_bytecode_table,
__module_deps__: [],

for_num: function(n) {
return bytecodes_by_num[n];
Expand Down
6 changes: 3 additions & 3 deletions ccanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ define(function() {
var make = function(canvas_id) {
var canvasElem_ = canvas_id ?
document.getElementById(canvas_id) :
document.createElement("canvas");
document.createElement("canvas");
var canvas_ = canvasElem_.getContext('2d');
var width_ = canvasElem_.width;
var height_ = canvasElem_.height;
Expand Down Expand Up @@ -108,8 +108,8 @@ var make = function(canvas_id) {
},
rect: function(x, y, w, h) {
// the rect primitive seems to have some issues on iOS
// (see above). We're going to implement it in terms of
// primitives.
// (see above). We're going to implement it in terms of
// primitives.
this.moveTo(x,y);
this.lineTo(x+w, y);
this.lineTo(x+w, y+h);
Expand Down
6 changes: 3 additions & 3 deletions eventtests.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ return function flapjax_tests(info, error) {
e.createNode(
[],
function (pulse) {
return pulse;
return pulse;
});

var secondsAdd1Node =
Expand All @@ -171,7 +171,7 @@ return function flapjax_tests(info, error) {
var bConstantNode = true;
// CSA HACK
e.createConstantNode = function(nodes, val) {
return e.createNode(nodes, function(pulse) { pulse.value = val; return pulse; });
return e.createNode(nodes, function(pulse) { pulse.value = val; return pulse; });
};

recConst = -2;
Expand Down Expand Up @@ -527,7 +527,7 @@ return function flapjax_tests(info, error) {
var bLift = true;

var bLiftE = true;
/*
/*
var toLiftAddXY = function (x, y) { return x + y; };
var liftX = flapjax.receiverE();
var liftY = e.createConstantNode([liftX], 3);
Expand Down
12 changes: 6 additions & 6 deletions extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ var now = function() {
Function.prototype.New = function() {
var object, result;
if (typeof(this.prototype)==="object") {
object = Object.create(this.prototype);
object = Object.create(this.prototype);
} else {
object = {};
object = {};
}
result = this.apply(object, arguments);
if (typeof(result)==="object") {
return result;
return result;
}
return object;
};
Expand All @@ -46,11 +46,11 @@ Object['Throw'] = function(obj) {
// subroutine inside a bodyBlock)
Object['Try'] = function(_this_, bodyBlock, catchBlock, finallyBlock) {
try {
bodyBlock.call(_this_);
bodyBlock.call(_this_);
} catch(e) {
if (catchBlock) catchBlock.call(_this_, e);
if (catchBlock) catchBlock.call(_this_, e);
} finally {
if (finallyBlock) finallyBlock.call(_this_);
if (finallyBlock) finallyBlock.call(_this_);
}
};

Expand Down
22 changes: 11 additions & 11 deletions gfx/Color.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Simple Color abstraction, based on Lessphic.
define(['./constructor'], function(constructor) {
var Color = {
a: 1, /* default value (fully opaque) */
__init__: function Color_ (r, g, b, a/*optional*/) {
a: 1, /* default value (fully opaque) */
__init__: function Color_ (r, g, b, a/*optional*/) {
this.r = r;
this.g = g;
this.b = b;
if (arguments.length >= 4 && a !== this.a) {
this.a = a;
}
},
From8888: function(r8, g8, b8, a8) {
if (arguments.length >= 4 && a !== this.a) {
this.a = a;
}
},
From8888: function(r8, g8, b8, a8) {
if (arguments.length < 4) { a8 = 255; }
return Color.New(r8/255, g8/255, b8/255, a8/255);
},
},
mixedWith: function(color, ratio/*optional*/) {
if (ratio===undefined) { ratio = 0.5; }
var n = 1 - ratio;
Expand Down Expand Up @@ -46,9 +46,9 @@ define(['./constructor'], function(constructor) {
// this is a hack to get colors to pretty print in the javascript console
// by making them appear to be instances of singleton classes.
var namedColor = function(f, r, g, b) {
var c = Color.New(r, g, b);
c.constructor = f;
return c;
var c = Color.New(r, g, b);
c.constructor = f;
return c;
};

Color.white = namedColor(function white(){}, 1, 1, 1);
Expand Down
36 changes: 18 additions & 18 deletions gfx/Point.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@ define(['./constructor'], function(constructor) {
var Point = { x:0, y:0 };
Point.New = constructor(Point);
Point.__init__ = function Point_ (x, y) {
// allow passing a Point as first argument
if (typeof(x)==="object") { y=x.y; x=x.x; }
if (x !== 0) { this.x = x; }
if (y !== 0) { this.y = y; }
// allow passing a Point as first argument
if (typeof(x)==="object") { y=x.y; x=x.x; }
if (x !== 0) { this.x = x; }
if (y !== 0) { this.y = y; }
};
Point.zero = Point.New(0,0);
Point.polar = function(r, theta) {
return Point.New(r * Math.cos(theta), r * Math.sin(theta));
return Point.New(r * Math.cos(theta), r * Math.sin(theta));
};
Point.add = function(x,y) {
// allow passing a Point as first argument
if (typeof(x)==="object") { y=x.y; x=x.x; }
if (x===0 && y===0) { return this; } // optimization
return Point.New(this.x + x, this.y + y);
// allow passing a Point as first argument
if (typeof(x)==="object") { y=x.y; x=x.x; }
if (x===0 && y===0) { return this; } // optimization
return Point.New(this.x + x, this.y + y);
};
Point.sub = function(x,y) {
// allow passing a Point as first argument
if (typeof(x)==="object") { y=x.y; x=x.x; }
if (x===0 && y===0) { return this; } // optimization
return Point.New(this.x - x, this.y - y);
// allow passing a Point as first argument
if (typeof(x)==="object") { y=x.y; x=x.x; }
if (x===0 && y===0) { return this; } // optimization
return Point.New(this.x - x, this.y - y);
};
Point.negate = function() {
if (this.isZero()) { return this; } // optimization
return Point.New(-this.x, -this.y);
if (this.isZero()) { return this; } // optimization
return Point.New(-this.x, -this.y);
};
Point.eq = function(pt) {
if (this === pt) { return true; } // optimization
return this.x === pt.x && this.y === pt.y;
if (this === pt) { return true; } // optimization
return this.x === pt.x && this.y === pt.y;
};
Point.isZero = function() { return this.x===0 && this.y===0; };
Point.toString = function() {
return "("+this.x+","+this.y+")";
return "("+this.x+","+this.y+")";
};
return Point;
});
2 changes: 1 addition & 1 deletion html-escape.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ define(function() {
var table = { "<":"&lt;", ">":"&gt;", "&":"&amp;" };
var replacer = function(ss) { return table[ss]; };
return function html_escape(s) {
return s.replace(/[<>&]/g, replacer);
return s.replace(/[<>&]/g, replacer);
};
});
Loading

0 comments on commit 47f9485

Please sign in to comment.