mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-20 01:37:50 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,168 @@
|
||||
package com.adobe.crypto
|
||||
{
|
||||
import com.adobe.utils.IntUtil;
|
||||
|
||||
public class MD5
|
||||
{
|
||||
|
||||
public function MD5()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function hash(param1:String) : String
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:int = 0;
|
||||
var _loc8_:int = 0;
|
||||
var _loc9_:int = 0;
|
||||
var _loc2_:int = 1732584193;
|
||||
var _loc3_:int = -271733879;
|
||||
var _loc4_:int = -1732584194;
|
||||
var _loc5_:int = 271733878;
|
||||
var _loc10_:Array = createBlocks(param1);
|
||||
var _loc11_:int = int(_loc10_.length);
|
||||
var _loc12_:int = 0;
|
||||
while(_loc12_ < _loc11_)
|
||||
{
|
||||
_loc6_ = _loc2_;
|
||||
_loc7_ = _loc3_;
|
||||
_loc8_ = _loc4_;
|
||||
_loc9_ = _loc5_;
|
||||
_loc2_ = ff(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 0],7,-680876936);
|
||||
_loc5_ = ff(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 1],12,-389564586);
|
||||
_loc4_ = ff(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 2],17,606105819);
|
||||
_loc3_ = ff(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 3],22,-1044525330);
|
||||
_loc2_ = ff(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 4],7,-176418897);
|
||||
_loc5_ = ff(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 5],12,1200080426);
|
||||
_loc4_ = ff(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 6],17,-1473231341);
|
||||
_loc3_ = ff(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 7],22,-45705983);
|
||||
_loc2_ = ff(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 8],7,1770035416);
|
||||
_loc5_ = ff(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 9],12,-1958414417);
|
||||
_loc4_ = ff(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 10],17,-42063);
|
||||
_loc3_ = ff(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 11],22,-1990404162);
|
||||
_loc2_ = ff(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 12],7,1804603682);
|
||||
_loc5_ = ff(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 13],12,-40341101);
|
||||
_loc4_ = ff(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 14],17,-1502002290);
|
||||
_loc3_ = ff(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 15],22,1236535329);
|
||||
_loc2_ = gg(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 1],5,-165796510);
|
||||
_loc5_ = gg(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 6],9,-1069501632);
|
||||
_loc4_ = gg(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 11],14,643717713);
|
||||
_loc3_ = gg(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 0],20,-373897302);
|
||||
_loc2_ = gg(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 5],5,-701558691);
|
||||
_loc5_ = gg(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 10],9,38016083);
|
||||
_loc4_ = gg(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 15],14,-660478335);
|
||||
_loc3_ = gg(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 4],20,-405537848);
|
||||
_loc2_ = gg(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 9],5,568446438);
|
||||
_loc5_ = gg(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 14],9,-1019803690);
|
||||
_loc4_ = gg(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 3],14,-187363961);
|
||||
_loc3_ = gg(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 8],20,1163531501);
|
||||
_loc2_ = gg(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 13],5,-1444681467);
|
||||
_loc5_ = gg(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 2],9,-51403784);
|
||||
_loc4_ = gg(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 7],14,1735328473);
|
||||
_loc3_ = gg(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 12],20,-1926607734);
|
||||
_loc2_ = hh(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 5],4,-378558);
|
||||
_loc5_ = hh(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 8],11,-2022574463);
|
||||
_loc4_ = hh(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 11],16,1839030562);
|
||||
_loc3_ = hh(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 14],23,-35309556);
|
||||
_loc2_ = hh(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 1],4,-1530992060);
|
||||
_loc5_ = hh(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 4],11,1272893353);
|
||||
_loc4_ = hh(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 7],16,-155497632);
|
||||
_loc3_ = hh(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 10],23,-1094730640);
|
||||
_loc2_ = hh(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 13],4,681279174);
|
||||
_loc5_ = hh(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 0],11,-358537222);
|
||||
_loc4_ = hh(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 3],16,-722521979);
|
||||
_loc3_ = hh(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 6],23,76029189);
|
||||
_loc2_ = hh(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 9],4,-640364487);
|
||||
_loc5_ = hh(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 12],11,-421815835);
|
||||
_loc4_ = hh(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 15],16,530742520);
|
||||
_loc3_ = hh(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 2],23,-995338651);
|
||||
_loc2_ = ii(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 0],6,-198630844);
|
||||
_loc5_ = ii(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 7],10,1126891415);
|
||||
_loc4_ = ii(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 14],15,-1416354905);
|
||||
_loc3_ = ii(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 5],21,-57434055);
|
||||
_loc2_ = ii(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 12],6,1700485571);
|
||||
_loc5_ = ii(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 3],10,-1894986606);
|
||||
_loc4_ = ii(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 10],15,-1051523);
|
||||
_loc3_ = ii(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 1],21,-2054922799);
|
||||
_loc2_ = ii(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 8],6,1873313359);
|
||||
_loc5_ = ii(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 15],10,-30611744);
|
||||
_loc4_ = ii(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 6],15,-1560198380);
|
||||
_loc3_ = ii(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 13],21,1309151649);
|
||||
_loc2_ = ii(_loc2_,_loc3_,_loc4_,_loc5_,_loc10_[_loc12_ + 4],6,-145523070);
|
||||
_loc5_ = ii(_loc5_,_loc2_,_loc3_,_loc4_,_loc10_[_loc12_ + 11],10,-1120210379);
|
||||
_loc4_ = ii(_loc4_,_loc5_,_loc2_,_loc3_,_loc10_[_loc12_ + 2],15,718787259);
|
||||
_loc3_ = ii(_loc3_,_loc4_,_loc5_,_loc2_,_loc10_[_loc12_ + 9],21,-343485551);
|
||||
_loc2_ += _loc6_;
|
||||
_loc3_ += _loc7_;
|
||||
_loc4_ += _loc8_;
|
||||
_loc5_ += _loc9_;
|
||||
_loc12_ += 16;
|
||||
}
|
||||
return IntUtil.toHex(_loc2_) + IntUtil.toHex(_loc3_) + IntUtil.toHex(_loc4_) + IntUtil.toHex(_loc5_);
|
||||
}
|
||||
|
||||
private static function f(param1:int, param2:int, param3:int) : int
|
||||
{
|
||||
return param1 & param2 | ~param1 & param3;
|
||||
}
|
||||
|
||||
private static function g(param1:int, param2:int, param3:int) : int
|
||||
{
|
||||
return param1 & param3 | param2 & ~param3;
|
||||
}
|
||||
|
||||
private static function h(param1:int, param2:int, param3:int) : int
|
||||
{
|
||||
return param1 ^ param2 ^ param3;
|
||||
}
|
||||
|
||||
private static function i(param1:int, param2:int, param3:int) : int
|
||||
{
|
||||
return param2 ^ (param1 | ~param3);
|
||||
}
|
||||
|
||||
private static function transform(param1:Function, param2:int, param3:int, param4:int, param5:int, param6:int, param7:int, param8:int) : int
|
||||
{
|
||||
var _loc9_:int = param2 + int(param1(param3,param4,param5)) + param6 + param8;
|
||||
return IntUtil.rol(_loc9_,param7) + param3;
|
||||
}
|
||||
|
||||
private static function ff(param1:int, param2:int, param3:int, param4:int, param5:int, param6:int, param7:int) : int
|
||||
{
|
||||
return transform(f,param1,param2,param3,param4,param5,param6,param7);
|
||||
}
|
||||
|
||||
private static function gg(param1:int, param2:int, param3:int, param4:int, param5:int, param6:int, param7:int) : int
|
||||
{
|
||||
return transform(g,param1,param2,param3,param4,param5,param6,param7);
|
||||
}
|
||||
|
||||
private static function hh(param1:int, param2:int, param3:int, param4:int, param5:int, param6:int, param7:int) : int
|
||||
{
|
||||
return transform(h,param1,param2,param3,param4,param5,param6,param7);
|
||||
}
|
||||
|
||||
private static function ii(param1:int, param2:int, param3:int, param4:int, param5:int, param6:int, param7:int) : int
|
||||
{
|
||||
return transform(i,param1,param2,param3,param4,param5,param6,param7);
|
||||
}
|
||||
|
||||
private static function createBlocks(param1:String) : Array
|
||||
{
|
||||
var _loc2_:Array = new Array();
|
||||
var _loc3_:int = param1.length * 8;
|
||||
var _loc4_:int = 255;
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc3_)
|
||||
{
|
||||
_loc2_[_loc5_ >> 5] |= (param1.charCodeAt(_loc5_ / 8) & _loc4_) << _loc5_ % 32;
|
||||
_loc5_ += 8;
|
||||
}
|
||||
_loc2_[_loc3_ >> 5] |= 128 << _loc3_ % 32;
|
||||
_loc2_[(_loc3_ + 64 >>> 9 << 4) + 14] = _loc3_;
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
public class JSON
|
||||
{
|
||||
|
||||
public function JSON()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function encode(param1:Object) : String
|
||||
{
|
||||
var _loc2_:JSONEncoder = new JSONEncoder(param1);
|
||||
return _loc2_.getString();
|
||||
}
|
||||
|
||||
public static function decode(param1:String) : *
|
||||
{
|
||||
var _loc2_:JSONDecoder = new JSONDecoder(param1);
|
||||
return _loc2_.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
public class JSONDecoder
|
||||
{
|
||||
|
||||
private var value:*;
|
||||
|
||||
private var tokenizer:JSONTokenizer;
|
||||
|
||||
private var token:JSONToken;
|
||||
|
||||
public function JSONDecoder(param1:String)
|
||||
{
|
||||
super();
|
||||
this.tokenizer = new JSONTokenizer(param1);
|
||||
this.nextToken();
|
||||
this.value = this.parseValue();
|
||||
}
|
||||
|
||||
public function getValue() : *
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
private function nextToken() : JSONToken
|
||||
{
|
||||
return this.token = this.tokenizer.getNextToken();
|
||||
}
|
||||
|
||||
private function parseArray() : Array
|
||||
{
|
||||
var _loc1_:Array = new Array();
|
||||
this.nextToken();
|
||||
if(this.token.type == JSONTokenType.RIGHT_BRACKET)
|
||||
{
|
||||
return _loc1_;
|
||||
}
|
||||
while(true)
|
||||
{
|
||||
_loc1_.push(this.parseValue());
|
||||
this.nextToken();
|
||||
if(this.token.type == JSONTokenType.RIGHT_BRACKET)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(this.token.type == JSONTokenType.COMMA)
|
||||
{
|
||||
this.nextToken();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tokenizer.parseError("Expecting ] or , but found " + this.token.value);
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function parseObject() : Object
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc1_:Object = new Object();
|
||||
this.nextToken();
|
||||
if(this.token.type == JSONTokenType.RIGHT_BRACE)
|
||||
{
|
||||
return _loc1_;
|
||||
}
|
||||
while(true)
|
||||
{
|
||||
if(this.token.type == JSONTokenType.STRING)
|
||||
{
|
||||
_loc2_ = String(this.token.value);
|
||||
this.nextToken();
|
||||
if(this.token.type == JSONTokenType.COLON)
|
||||
{
|
||||
this.nextToken();
|
||||
_loc1_[_loc2_] = this.parseValue();
|
||||
this.nextToken();
|
||||
if(this.token.type == JSONTokenType.RIGHT_BRACE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(this.token.type == JSONTokenType.COMMA)
|
||||
{
|
||||
this.nextToken();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tokenizer.parseError("Expecting } or , but found " + this.token.value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tokenizer.parseError("Expecting : but found " + this.token.value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.tokenizer.parseError("Expecting string but found " + this.token.value);
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function parseValue() : Object
|
||||
{
|
||||
switch(this.token.type)
|
||||
{
|
||||
case JSONTokenType.LEFT_BRACE:
|
||||
return this.parseObject();
|
||||
case JSONTokenType.LEFT_BRACKET:
|
||||
return this.parseArray();
|
||||
case JSONTokenType.STRING:
|
||||
case JSONTokenType.NUMBER:
|
||||
case JSONTokenType.TRUE:
|
||||
case JSONTokenType.FALSE:
|
||||
case JSONTokenType.NULL:
|
||||
return this.token.value;
|
||||
default:
|
||||
this.tokenizer.parseError("Unexpected " + this.token.value);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
import flash.utils.describeType;
|
||||
|
||||
public class JSONEncoder
|
||||
{
|
||||
|
||||
private var jsonString:String;
|
||||
|
||||
public function JSONEncoder(param1:*)
|
||||
{
|
||||
super();
|
||||
this.jsonString = this.convertToString(param1);
|
||||
}
|
||||
|
||||
public function getString() : String
|
||||
{
|
||||
return this.jsonString;
|
||||
}
|
||||
|
||||
private function convertToString(param1:*) : String
|
||||
{
|
||||
if(param1 is String)
|
||||
{
|
||||
return this.escapeString(param1 as String);
|
||||
}
|
||||
if(param1 is Number)
|
||||
{
|
||||
return isFinite(param1 as Number) ? param1.toString() : "null";
|
||||
}
|
||||
if(param1 is Boolean)
|
||||
{
|
||||
return param1 ? "true" : "false";
|
||||
}
|
||||
if(param1 is Array)
|
||||
{
|
||||
return this.arrayToString(param1 as Array);
|
||||
}
|
||||
if(param1 is Object && param1 != null)
|
||||
{
|
||||
return this.objectToString(param1);
|
||||
}
|
||||
return "null";
|
||||
}
|
||||
|
||||
private function escapeString(param1:String) : String
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc6_:String = null;
|
||||
var _loc7_:String = null;
|
||||
var _loc2_:String = "";
|
||||
var _loc4_:Number = param1.length;
|
||||
var _loc5_:int = 0;
|
||||
while(_loc5_ < _loc4_)
|
||||
{
|
||||
_loc3_ = param1.charAt(_loc5_);
|
||||
switch(_loc3_)
|
||||
{
|
||||
case "\"":
|
||||
_loc2_ += "\\\"";
|
||||
break;
|
||||
case "\\":
|
||||
_loc2_ += "\\\\";
|
||||
break;
|
||||
case "\b":
|
||||
_loc2_ += "\\b";
|
||||
break;
|
||||
case "\f":
|
||||
_loc2_ += "\\f";
|
||||
break;
|
||||
case "\n":
|
||||
_loc2_ += "\\n";
|
||||
break;
|
||||
case "\r":
|
||||
_loc2_ += "\\r";
|
||||
break;
|
||||
case "\t":
|
||||
_loc2_ += "\\t";
|
||||
break;
|
||||
default:
|
||||
if(_loc3_ < " ")
|
||||
{
|
||||
_loc6_ = _loc3_.charCodeAt(0).toString(16);
|
||||
_loc7_ = _loc6_.length == 2 ? "00" : "000";
|
||||
_loc2_ += "\\u" + _loc7_ + _loc6_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ += _loc3_;
|
||||
}
|
||||
}
|
||||
_loc5_++;
|
||||
}
|
||||
return "\"" + _loc2_ + "\"";
|
||||
}
|
||||
|
||||
private function arrayToString(param1:Array) : String
|
||||
{
|
||||
var _loc2_:String = "";
|
||||
var _loc3_:int = 0;
|
||||
while(_loc3_ < param1.length)
|
||||
{
|
||||
if(_loc2_.length > 0)
|
||||
{
|
||||
_loc2_ += ",";
|
||||
}
|
||||
_loc2_ += this.convertToString(param1[_loc3_]);
|
||||
_loc3_++;
|
||||
}
|
||||
return "[" + _loc2_ + "]";
|
||||
}
|
||||
|
||||
private function objectToString(param1:Object) : String
|
||||
{
|
||||
var value:Object = null;
|
||||
var key:String = null;
|
||||
var v:XML = null;
|
||||
var o:Object = param1;
|
||||
var s:String = "";
|
||||
var classInfo:XML = describeType(o);
|
||||
if(classInfo.@name.toString() == "Object")
|
||||
{
|
||||
for(key in o)
|
||||
{
|
||||
value = o[key];
|
||||
if(!(value is Function))
|
||||
{
|
||||
if(s.length > 0)
|
||||
{
|
||||
s += ",";
|
||||
}
|
||||
s += this.escapeString(key) + ":" + this.convertToString(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for each(v in classInfo..*.(name() == "variable" || name() == "accessor"))
|
||||
{
|
||||
if(s.length > 0)
|
||||
{
|
||||
s += ",";
|
||||
}
|
||||
s += this.escapeString(v.@name.toString()) + ":" + this.convertToString(o[v.@name]);
|
||||
}
|
||||
}
|
||||
return "{" + s + "}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
public class JSONParseError extends Error
|
||||
{
|
||||
|
||||
private var _location:int;
|
||||
|
||||
private var _text:String;
|
||||
|
||||
public function JSONParseError(param1:String = "", param2:int = 0, param3:String = "")
|
||||
{
|
||||
super(param1);
|
||||
this._location = param2;
|
||||
this._text = param3;
|
||||
}
|
||||
|
||||
public function get location() : int
|
||||
{
|
||||
return this._location;
|
||||
}
|
||||
|
||||
public function get text() : String
|
||||
{
|
||||
return this._text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
public class JSONToken
|
||||
{
|
||||
|
||||
private var _type:int;
|
||||
|
||||
private var _value:Object;
|
||||
|
||||
public function JSONToken(param1:int = -1, param2:Object = null)
|
||||
{
|
||||
super();
|
||||
this._type = param1;
|
||||
this._value = param2;
|
||||
}
|
||||
|
||||
public function get type() : int
|
||||
{
|
||||
return this._type;
|
||||
}
|
||||
|
||||
public function set type(param1:int) : void
|
||||
{
|
||||
this._type = param1;
|
||||
}
|
||||
|
||||
public function get value() : Object
|
||||
{
|
||||
return this._value;
|
||||
}
|
||||
|
||||
public function set value(param1:Object) : void
|
||||
{
|
||||
this._value = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
public class JSONTokenType
|
||||
{
|
||||
|
||||
public static const UNKNOWN:int = -1;
|
||||
|
||||
public static const COMMA:int = 0;
|
||||
|
||||
public static const LEFT_BRACE:int = 1;
|
||||
|
||||
public static const RIGHT_BRACE:int = 2;
|
||||
|
||||
public static const LEFT_BRACKET:int = 3;
|
||||
|
||||
public static const RIGHT_BRACKET:int = 4;
|
||||
|
||||
public static const COLON:int = 6;
|
||||
|
||||
public static const TRUE:int = 7;
|
||||
|
||||
public static const FALSE:int = 8;
|
||||
|
||||
public static const NULL:int = 9;
|
||||
|
||||
public static const STRING:int = 10;
|
||||
|
||||
public static const NUMBER:int = 11;
|
||||
|
||||
public function JSONTokenType()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,352 @@
|
||||
package com.adobe.serialization.json
|
||||
{
|
||||
public class JSONTokenizer
|
||||
{
|
||||
|
||||
private var obj:Object;
|
||||
|
||||
private var jsonString:String;
|
||||
|
||||
private var loc:int;
|
||||
|
||||
private var ch:String;
|
||||
|
||||
public function JSONTokenizer(param1:String)
|
||||
{
|
||||
super();
|
||||
this.jsonString = param1;
|
||||
this.loc = 0;
|
||||
this.nextChar();
|
||||
}
|
||||
|
||||
public function getNextToken() : JSONToken
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
var _loc3_:String = null;
|
||||
var _loc4_:String = null;
|
||||
var _loc1_:JSONToken = new JSONToken();
|
||||
this.skipIgnored();
|
||||
switch(this.ch)
|
||||
{
|
||||
case "{":
|
||||
_loc1_.type = JSONTokenType.LEFT_BRACE;
|
||||
_loc1_.value = "{";
|
||||
this.nextChar();
|
||||
break;
|
||||
case "}":
|
||||
_loc1_.type = JSONTokenType.RIGHT_BRACE;
|
||||
_loc1_.value = "}";
|
||||
this.nextChar();
|
||||
break;
|
||||
case "[":
|
||||
_loc1_.type = JSONTokenType.LEFT_BRACKET;
|
||||
_loc1_.value = "[";
|
||||
this.nextChar();
|
||||
break;
|
||||
case "]":
|
||||
_loc1_.type = JSONTokenType.RIGHT_BRACKET;
|
||||
_loc1_.value = "]";
|
||||
this.nextChar();
|
||||
break;
|
||||
case ",":
|
||||
_loc1_.type = JSONTokenType.COMMA;
|
||||
_loc1_.value = ",";
|
||||
this.nextChar();
|
||||
break;
|
||||
case ":":
|
||||
_loc1_.type = JSONTokenType.COLON;
|
||||
_loc1_.value = ":";
|
||||
this.nextChar();
|
||||
break;
|
||||
case "t":
|
||||
_loc2_ = "t" + this.nextChar() + this.nextChar() + this.nextChar();
|
||||
if(_loc2_ == "true")
|
||||
{
|
||||
_loc1_.type = JSONTokenType.TRUE;
|
||||
_loc1_.value = true;
|
||||
this.nextChar();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.parseError("Expecting \'true\' but found " + _loc2_);
|
||||
}
|
||||
break;
|
||||
case "f":
|
||||
_loc3_ = "f" + this.nextChar() + this.nextChar() + this.nextChar() + this.nextChar();
|
||||
if(_loc3_ == "false")
|
||||
{
|
||||
_loc1_.type = JSONTokenType.FALSE;
|
||||
_loc1_.value = false;
|
||||
this.nextChar();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.parseError("Expecting \'false\' but found " + _loc3_);
|
||||
}
|
||||
break;
|
||||
case "n":
|
||||
_loc4_ = "n" + this.nextChar() + this.nextChar() + this.nextChar();
|
||||
if(_loc4_ == "null")
|
||||
{
|
||||
_loc1_.type = JSONTokenType.NULL;
|
||||
_loc1_.value = null;
|
||||
this.nextChar();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.parseError("Expecting \'null\' but found " + _loc4_);
|
||||
}
|
||||
break;
|
||||
case "\"":
|
||||
_loc1_ = this.readString();
|
||||
break;
|
||||
default:
|
||||
if(this.isDigit(this.ch) || this.ch == "-")
|
||||
{
|
||||
_loc1_ = this.readNumber();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.ch == "")
|
||||
{
|
||||
return null;
|
||||
}
|
||||
this.parseError("Unexpected " + this.ch + " encountered");
|
||||
}
|
||||
}
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function readString() : JSONToken
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc4_:int = 0;
|
||||
var _loc1_:JSONToken = new JSONToken();
|
||||
_loc1_.type = JSONTokenType.STRING;
|
||||
var _loc2_:String = "";
|
||||
this.nextChar();
|
||||
while(this.ch != "\"" && this.ch != "")
|
||||
{
|
||||
if(this.ch == "\\")
|
||||
{
|
||||
this.nextChar();
|
||||
switch(this.ch)
|
||||
{
|
||||
case "\"":
|
||||
_loc2_ += "\"";
|
||||
break;
|
||||
case "/":
|
||||
_loc2_ += "/";
|
||||
break;
|
||||
case "\\":
|
||||
_loc2_ += "\\";
|
||||
break;
|
||||
case "b":
|
||||
_loc2_ += "\b";
|
||||
break;
|
||||
case "f":
|
||||
_loc2_ += "\f";
|
||||
break;
|
||||
case "n":
|
||||
_loc2_ += "\n";
|
||||
break;
|
||||
case "r":
|
||||
_loc2_ += "\r";
|
||||
break;
|
||||
case "t":
|
||||
_loc2_ += "\t";
|
||||
break;
|
||||
case "u":
|
||||
_loc3_ = "";
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < 4)
|
||||
{
|
||||
if(!this.isHexDigit(this.nextChar()))
|
||||
{
|
||||
this.parseError(" Excepted a hex digit, but found: " + this.ch);
|
||||
}
|
||||
_loc3_ += this.ch;
|
||||
_loc4_++;
|
||||
}
|
||||
_loc2_ += String.fromCharCode(parseInt(_loc3_,16));
|
||||
break;
|
||||
default:
|
||||
_loc2_ += "\\" + this.ch;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc2_ += this.ch;
|
||||
}
|
||||
this.nextChar();
|
||||
}
|
||||
if(this.ch == "")
|
||||
{
|
||||
this.parseError("Unterminated string literal");
|
||||
}
|
||||
this.nextChar();
|
||||
_loc1_.value = _loc2_;
|
||||
return _loc1_;
|
||||
}
|
||||
|
||||
private function readNumber() : JSONToken
|
||||
{
|
||||
var _loc1_:JSONToken = new JSONToken();
|
||||
_loc1_.type = JSONTokenType.NUMBER;
|
||||
var _loc2_:String = "";
|
||||
if(this.ch == "-")
|
||||
{
|
||||
_loc2_ += "-";
|
||||
this.nextChar();
|
||||
}
|
||||
if(!this.isDigit(this.ch))
|
||||
{
|
||||
this.parseError("Expecting a digit");
|
||||
}
|
||||
if(this.ch == "0")
|
||||
{
|
||||
_loc2_ += this.ch;
|
||||
this.nextChar();
|
||||
if(this.isDigit(this.ch))
|
||||
{
|
||||
this.parseError("A digit cannot immediately follow 0");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(this.isDigit(this.ch))
|
||||
{
|
||||
_loc2_ += this.ch;
|
||||
this.nextChar();
|
||||
}
|
||||
}
|
||||
if(this.ch == ".")
|
||||
{
|
||||
_loc2_ += ".";
|
||||
this.nextChar();
|
||||
if(!this.isDigit(this.ch))
|
||||
{
|
||||
this.parseError("Expecting a digit");
|
||||
}
|
||||
while(this.isDigit(this.ch))
|
||||
{
|
||||
_loc2_ += this.ch;
|
||||
this.nextChar();
|
||||
}
|
||||
}
|
||||
if(this.ch == "e" || this.ch == "E")
|
||||
{
|
||||
_loc2_ += "e";
|
||||
this.nextChar();
|
||||
if(this.ch == "+" || this.ch == "-")
|
||||
{
|
||||
_loc2_ += this.ch;
|
||||
this.nextChar();
|
||||
}
|
||||
if(!this.isDigit(this.ch))
|
||||
{
|
||||
this.parseError("Scientific notation number needs exponent value");
|
||||
}
|
||||
while(this.isDigit(this.ch))
|
||||
{
|
||||
_loc2_ += this.ch;
|
||||
this.nextChar();
|
||||
}
|
||||
}
|
||||
var _loc3_:Number = Number(_loc2_);
|
||||
if(isFinite(_loc3_) && !isNaN(_loc3_))
|
||||
{
|
||||
_loc1_.value = _loc3_;
|
||||
return _loc1_;
|
||||
}
|
||||
this.parseError("Number " + _loc3_ + " is not valid!");
|
||||
return null;
|
||||
}
|
||||
|
||||
private function nextChar() : String
|
||||
{
|
||||
return this.ch = this.jsonString.charAt(this.loc++);
|
||||
}
|
||||
|
||||
private function skipIgnored() : void
|
||||
{
|
||||
this.skipWhite();
|
||||
this.skipComments();
|
||||
this.skipWhite();
|
||||
}
|
||||
|
||||
private function skipComments() : void
|
||||
{
|
||||
if(this.ch == "/")
|
||||
{
|
||||
this.nextChar();
|
||||
switch(this.ch)
|
||||
{
|
||||
case "/":
|
||||
do
|
||||
{
|
||||
this.nextChar();
|
||||
}
|
||||
while(this.ch != "\n" && this.ch != "");
|
||||
this.nextChar();
|
||||
break;
|
||||
case "*":
|
||||
this.nextChar();
|
||||
while(true)
|
||||
{
|
||||
if(this.ch == "*")
|
||||
{
|
||||
this.nextChar();
|
||||
if(this.ch == "/")
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.nextChar();
|
||||
}
|
||||
if(this.ch == "")
|
||||
{
|
||||
this.parseError("Multi-line comment not closed");
|
||||
}
|
||||
}
|
||||
this.nextChar();
|
||||
break;
|
||||
default:
|
||||
this.parseError("Unexpected " + this.ch + " encountered (expecting \'/\' or \'*\' )");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function skipWhite() : void
|
||||
{
|
||||
while(this.isWhiteSpace(this.ch))
|
||||
{
|
||||
this.nextChar();
|
||||
}
|
||||
}
|
||||
|
||||
private function isWhiteSpace(param1:String) : Boolean
|
||||
{
|
||||
return param1 == " " || param1 == "\t" || param1 == "\n";
|
||||
}
|
||||
|
||||
private function isDigit(param1:String) : Boolean
|
||||
{
|
||||
return param1 >= "0" && param1 <= "9";
|
||||
}
|
||||
|
||||
private function isHexDigit(param1:String) : Boolean
|
||||
{
|
||||
var _loc2_:String = param1.toUpperCase();
|
||||
return this.isDigit(param1) || _loc2_ >= "A" && _loc2_ <= "F";
|
||||
}
|
||||
|
||||
public function parseError(param1:String) : void
|
||||
{
|
||||
throw new JSONParseError(param1,this.loc,this.jsonString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.adobe.utils
|
||||
{
|
||||
public class IntUtil
|
||||
{
|
||||
|
||||
private static var hexChars:String = "0123456789abcdef";
|
||||
|
||||
public function IntUtil()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function rol(param1:int, param2:int) : int
|
||||
{
|
||||
return param1 << param2 | param1 >>> 32 - param2;
|
||||
}
|
||||
|
||||
public static function ror(param1:int, param2:int) : uint
|
||||
{
|
||||
var _loc3_:int = 32 - param2;
|
||||
return param1 << _loc3_ | param1 >>> 32 - _loc3_;
|
||||
}
|
||||
|
||||
public static function toHex(param1:int, param2:Boolean = false) : String
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:String = "";
|
||||
if(param2)
|
||||
{
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < 4)
|
||||
{
|
||||
_loc3_ += hexChars.charAt(param1 >> (3 - _loc4_) * 8 + 4 & 0x0F) + hexChars.charAt(param1 >> (3 - _loc4_) * 8 & 0x0F);
|
||||
_loc4_++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < 4)
|
||||
{
|
||||
_loc3_ += hexChars.charAt(param1 >> _loc5_ * 8 + 4 & 0x0F) + hexChars.charAt(param1 >> _loc5_ * 8 & 0x0F);
|
||||
_loc5_++;
|
||||
}
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.adobe.utils
|
||||
{
|
||||
public class StringUtil
|
||||
{
|
||||
|
||||
public function StringUtil()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function stringsAreEqual(param1:String, param2:String, param3:Boolean) : Boolean
|
||||
{
|
||||
if(param3)
|
||||
{
|
||||
return param1 == param2;
|
||||
}
|
||||
return param1.toUpperCase() == param2.toUpperCase();
|
||||
}
|
||||
|
||||
public static function trim(param1:String) : String
|
||||
{
|
||||
return StringUtil.ltrim(StringUtil.rtrim(param1));
|
||||
}
|
||||
|
||||
public static function ltrim(param1:String) : String
|
||||
{
|
||||
var _loc2_:Number = param1.length;
|
||||
var _loc3_:Number = 0;
|
||||
while(_loc3_ < _loc2_)
|
||||
{
|
||||
if(param1.charCodeAt(_loc3_) > 32)
|
||||
{
|
||||
return param1.substring(_loc3_);
|
||||
}
|
||||
_loc3_++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function rtrim(param1:String) : String
|
||||
{
|
||||
var _loc2_:Number = param1.length;
|
||||
var _loc3_:Number = _loc2_;
|
||||
while(_loc3_ > 0)
|
||||
{
|
||||
if(param1.charCodeAt(_loc3_ - 1) > 32)
|
||||
{
|
||||
return param1.substring(0,_loc3_);
|
||||
}
|
||||
_loc3_--;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function beginsWith(param1:String, param2:String) : Boolean
|
||||
{
|
||||
return param2 == param1.substring(0,param2.length);
|
||||
}
|
||||
|
||||
public static function endsWith(param1:String, param2:String) : Boolean
|
||||
{
|
||||
return param2 == param1.substring(param1.length - param2.length);
|
||||
}
|
||||
|
||||
public static function remove(param1:String, param2:String) : String
|
||||
{
|
||||
return StringUtil.replace(param1,param2,"");
|
||||
}
|
||||
|
||||
public static function replace(param1:String, param2:String, param3:String) : String
|
||||
{
|
||||
var _loc9_:Number = NaN;
|
||||
var _loc4_:String = new String();
|
||||
var _loc5_:Boolean = false;
|
||||
var _loc6_:Number = param1.length;
|
||||
var _loc7_:Number = param2.length;
|
||||
var _loc8_:Number = 0;
|
||||
for(; _loc8_ < _loc6_; _loc8_++)
|
||||
{
|
||||
if(param1.charAt(_loc8_) == param2.charAt(0))
|
||||
{
|
||||
_loc5_ = true;
|
||||
_loc9_ = 0;
|
||||
while(_loc9_ < _loc7_)
|
||||
{
|
||||
if(param1.charAt(_loc8_ + _loc9_) != param2.charAt(_loc9_))
|
||||
{
|
||||
_loc5_ = false;
|
||||
break;
|
||||
}
|
||||
_loc9_++;
|
||||
}
|
||||
if(_loc5_)
|
||||
{
|
||||
_loc4_ += param3;
|
||||
_loc8_ += _loc7_ - 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
_loc4_ += param1.charAt(_loc8_);
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user