Browse files

Merge pull request #1 from xdissent/master

Bitwise operator-safe state values.
  • Loading branch information...
2 parents d8af74b + 21ab780 commit 02767b2ce725343e01f294189b9abb088a936de0 @boneheadmed committed Jun 11, 2011
Showing with 13 additions and 7 deletions.
  1. +13 −7 symbols.js
View
20 symbols.js
@@ -27,15 +27,21 @@ ig.Symbols = ig.Class.extend({
if (typeof classes == "undefined")
classes = [ig.Entity];
- var nameArray = names.split(" ");
+ var nameArray = names.split(" "),
+ nameArrayLen = nameArray.length;
+
+ if (nameArrayLen > 30) {
+ throw("Error: ig.Symbols allows a maximum of 30 symbol definitions.");
+ }
- for(i =0; i < classes.length; i++){
+ for(var i = 0; i < classes.length; i++){
var currentClass = classes[i];
- var j = 0;
- for(j = 0; j < nameArray.length; j++){
- nameArray[j].replace(/^\s+|\s+$/g,"");
- if (nameArray[j] != "")
- currentClass[nameArray[j]] = j;
+ for(var j = 0; j < nameArrayLen; j++){
+ var name = nameArray[j];
+ name.replace(/^\s+|\s+$/g, "");
+ if (name) {
+ currentClass[name] = 0x1 << j;
+ }
}
}
ig.Symbols.instance = this;

0 comments on commit 02767b2

Please sign in to comment.