Skip to content
Snippets Groups Projects
Commit fd5932b3 authored by mcmlxxix's avatar mcmlxxix
Browse files

move Cursor, Offset getters/setters to prototype (squeeze out that last drop of memory savings)

parent 6ae64ef1
No related branches found
No related tags found
No related merge requests found
...@@ -1674,31 +1674,34 @@ function Cursor(x,y,frame) { ...@@ -1674,31 +1674,34 @@ function Cursor(x,y,frame) {
y:undefined, y:undefined,
frame:undefined frame:undefined
} }
this.__defineGetter__("x", function() {
if(frame instanceof Frame)
this.__properties__.frame = frame;
else
throw("the frame is not a frame");
this.x = x;
this.y = y;
}
Cursor.prototype.__defineGetter__("x", function() {
return this.__properties__.x; return this.__properties__.x;
}); });
this.__defineSetter__("x", function(x) { Cursor.prototype.__defineSetter__("x", function(x) {
if(isNaN(x)) if(isNaN(x))
throw("invalid x coordinate: " + x); throw("invalid x coordinate: " + x);
this.__properties__.x = x; this.__properties__.x = x;
}); });
this.__defineGetter__("y", function() { Cursor.prototype.__defineGetter__("y", function() {
return this.__properties__.y; return this.__properties__.y;
}); });
this.__defineSetter__("y", function(y) { Cursor.prototype.__defineSetter__("y", function(y) {
if(isNaN(y)) if(isNaN(y))
throw("invalid y coordinate: " + y); throw("invalid y coordinate: " + y);
this.__properties__.y = y; this.__properties__.y = y;
}); });
if(frame instanceof Frame)
this.__properties__.frame = frame;
else
throw("the frame is not a frame");
this.x = x;
this.y = y;
}
/* self-validating scroll offset object */ /* self-validating scroll offset object */
function Offset(x,y,frame) { function Offset(x,y,frame) {
...@@ -1707,36 +1710,33 @@ function Offset(x,y,frame) { ...@@ -1707,36 +1710,33 @@ function Offset(x,y,frame) {
y:undefined, y:undefined,
frame:undefined frame:undefined
} }
this.__defineGetter__("x", function() {
if(frame instanceof Frame)
this.__properties__.frame = frame;
else
throw("the frame is not a frame");
this.x = x;
this.y = y;
}
Offset.prototype.__defineGetter__("x", function() {
return this.__properties__.x; return this.__properties__.x;
}); });
this.__defineSetter__("x", function(x) { Offset.prototype.__defineSetter__("x", function(x) {
if(x == undefined) if(x == undefined)
throw("invalid x offset: " + x); throw("invalid x offset: " + x);
else if(x < 0) else if(x < 0)
x = 0; x = 0;
/* else if(x > this.__properties__.frame.data_width - this.__properties__.frame.width) this.__properties__.x = x;
x = this.__properties__.frame.data_width - this.__properties__.frame.width;
*/ this.__properties__.x = x;
}); });
this.__defineGetter__("y", function() { Offset.prototype.__defineGetter__("y", function() {
return this.__properties__.y; return this.__properties__.y;
}); });
this.__defineSetter__("y", function(y) { Offset.prototype.__defineSetter__("y", function(y) {
if(y == undefined) if(y == undefined)
throw("invalid y offset: " + y); throw("invalid y offset: " + y);
else if(y < 0) else if(y < 0)
y = 0; y = 0;
/* else if(y > this.__properties__.frame.data_height - this.__properties__.frame.height) this.__properties__.y = y;
y = this.__properties__.frame.data_height - this.__properties__.frame.height;
*/ this.__properties__.y = y;
}); });
if(frame instanceof Frame)
this.__properties__.frame = frame;
else
throw("the frame is not a frame");
this.x = x;
this.y = y;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment