Skip to content

Commit

Permalink
Removed batch attribute accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Feb 2, 2016
1 parent d6cc65f commit a3e4ceb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 344 deletions.
172 changes: 0 additions & 172 deletions api/latest/scenejs.js
Expand Up @@ -7960,178 +7960,6 @@ SceneJS.Node.prototype.findParentByType = function (type) {
return parent;
};


/**
* Given a map of name-value pairs, calls a getter method for each name,
* feeding into it the corresponding value.
*
* @param attr
* @param value
* @return {*}
*/
SceneJS.Node.prototype.set = function (attr, value) {

if (typeof attr == "object") { // Attribute map - recurse for each attribute
for (var subAttr in attr) {
if (attr.hasOwnProperty(subAttr)) {
this.set(subAttr, attr[subAttr]);
}
}
return;
}

if (this._set) {
var method = this._set[attr];
if (method) {
return method.call(this, value);
}
}

return this._createAccessor("set", attr, value);
};

SceneJS.Node.prototype.get = function (attr) {

if (this._get) {
var method = this._get[attr];
if (method) {
return method.call(this);
}
}

return this._createAccessor("get", attr);
};

SceneJS.Node.prototype.add = function (attr, value) {

if (typeof attr == "object") { // Attribute map - recurse for each attribute
for (var subAttr in attr) {
if (attr.hasOwnProperty(subAttr)) {
this.add(subAttr, attr[subAttr]);
}
}
return;
}

if (this._add) {
var method = this._add[attr];
if (method) {
return method.call(this, value);
}
}

return this._createAccessor("add", attr, value);
};

SceneJS.Node.prototype.inc = function (attr, value) {

if (typeof attr == "object") { // Attribute map - recurse for each attribute
for (var subAttr in attr) {
if (attr.hasOwnProperty(subAttr)) {
this.inc(subAttr, attr[subAttr]);
}
}
return;
}

if (this._inc) {
var method = this._inc[attr];
if (method) {
return method.call(this, value);
}
}

return this._createAccessor("inc", attr, value);
};

SceneJS.Node.prototype.insert = function (attr, value) {

if (typeof attr == "object") { // Attribute map - recurse for each attribute
for (var subAttr in attr) {
if (attr.hasOwnProperty(subAttr)) {
this.insert(subAttr, attr[subAttr]);
}
}
return;
}

if (this._set) {
var method = this._set[attr];
if (method) {
return method.call(this, value);
}
}

return this._createAccessor("insert", attr, value);
};

SceneJS.Node.prototype.remove = function (attr, value) {

if (typeof attr == "object") { // Attribute map - recurse for each attribute
for (var subAttr in attr) {
if (attr.hasOwnProperty(subAttr)) {
this.remove(subAttr, attr[subAttr]);
}
}
return;
}

if (this._remove) {
var method = this._remove[attr];
if (method) {
return method.call(this, value);
}
}

return this._createAccessor("remove", attr, value);
};

SceneJS.Node.prototype._createAccessor = function (op, attr, value) {

var methodName = op + attr.substr(0, 1).toUpperCase() + attr.substr(1);

var method = this[methodName];

if (!method) {
throw "Method not found on node: '" + methodName + "'";
}

//var proto = (this.type == "node") ? SceneJS.Node.prototype : this._engine.nodeTypes[this.type].prototype;

var proto = this.__proto__;

var accessors;
switch (op) {
case "set":
accessors = (proto._set || (proto._set = {}));
break;

case "get":
accessors = (proto._get || (proto._get = {}));
break;

case "inc":
accessors = (proto._inc || (proto._inc = {}));
break;

case "add":
accessors = (proto._add || (proto._add = {}));
break;

case "insert":
accessors = (proto._insert || (proto._insert = {}));
break;

case "remove":
accessors = (proto._remove || (proto._remove = {}));
break;
}

accessors[attr] = method;

return method.call(this, value); // value can be undefined
};

/** Binds a listener to an event on the selected node
*
* @param {String} name Event name
Expand Down
172 changes: 0 additions & 172 deletions src/core/scene/node.js
Expand Up @@ -1076,178 +1076,6 @@ SceneJS.Node.prototype.findParentByType = function (type) {
return parent;
};


/**
* Given a map of name-value pairs, calls a getter method for each name,
* feeding into it the corresponding value.
*
* @param attr
* @param value
* @return {*}
*/
SceneJS.Node.prototype.set = function (attr, value) {

if (typeof attr == "object") { // Attribute map - recurse for each attribute
for (var subAttr in attr) {
if (attr.hasOwnProperty(subAttr)) {
this.set(subAttr, attr[subAttr]);
}
}
return;
}

if (this._set) {
var method = this._set[attr];
if (method) {
return method.call(this, value);
}
}

return this._createAccessor("set", attr, value);
};

SceneJS.Node.prototype.get = function (attr) {

if (this._get) {
var method = this._get[attr];
if (method) {
return method.call(this);
}
}

return this._createAccessor("get", attr);
};

SceneJS.Node.prototype.add = function (attr, value) {

if (typeof attr == "object") { // Attribute map - recurse for each attribute
for (var subAttr in attr) {
if (attr.hasOwnProperty(subAttr)) {
this.add(subAttr, attr[subAttr]);
}
}
return;
}

if (this._add) {
var method = this._add[attr];
if (method) {
return method.call(this, value);
}
}

return this._createAccessor("add", attr, value);
};

SceneJS.Node.prototype.inc = function (attr, value) {

if (typeof attr == "object") { // Attribute map - recurse for each attribute
for (var subAttr in attr) {
if (attr.hasOwnProperty(subAttr)) {
this.inc(subAttr, attr[subAttr]);
}
}
return;
}

if (this._inc) {
var method = this._inc[attr];
if (method) {
return method.call(this, value);
}
}

return this._createAccessor("inc", attr, value);
};

SceneJS.Node.prototype.insert = function (attr, value) {

if (typeof attr == "object") { // Attribute map - recurse for each attribute
for (var subAttr in attr) {
if (attr.hasOwnProperty(subAttr)) {
this.insert(subAttr, attr[subAttr]);
}
}
return;
}

if (this._set) {
var method = this._set[attr];
if (method) {
return method.call(this, value);
}
}

return this._createAccessor("insert", attr, value);
};

SceneJS.Node.prototype.remove = function (attr, value) {

if (typeof attr == "object") { // Attribute map - recurse for each attribute
for (var subAttr in attr) {
if (attr.hasOwnProperty(subAttr)) {
this.remove(subAttr, attr[subAttr]);
}
}
return;
}

if (this._remove) {
var method = this._remove[attr];
if (method) {
return method.call(this, value);
}
}

return this._createAccessor("remove", attr, value);
};

SceneJS.Node.prototype._createAccessor = function (op, attr, value) {

var methodName = op + attr.substr(0, 1).toUpperCase() + attr.substr(1);

var method = this[methodName];

if (!method) {
throw "Method not found on node: '" + methodName + "'";
}

//var proto = (this.type == "node") ? SceneJS.Node.prototype : this._engine.nodeTypes[this.type].prototype;

var proto = this.__proto__;

var accessors;
switch (op) {
case "set":
accessors = (proto._set || (proto._set = {}));
break;

case "get":
accessors = (proto._get || (proto._get = {}));
break;

case "inc":
accessors = (proto._inc || (proto._inc = {}));
break;

case "add":
accessors = (proto._add || (proto._add = {}));
break;

case "insert":
accessors = (proto._insert || (proto._insert = {}));
break;

case "remove":
accessors = (proto._remove || (proto._remove = {}));
break;
}

accessors[attr] = method;

return method.call(this, value); // value can be undefined
};

/** Binds a listener to an event on the selected node
*
* @param {String} name Event name
Expand Down

0 comments on commit a3e4ceb

Please sign in to comment.