提交 15deafae 编写于 作者: D Dale Stammen

added support for parsing ArrayBuffer from XHR2 response

上级 ddc9af90
......@@ -585,13 +585,24 @@ CTM.InterleavedStream.prototype.writeByte = function(value){
CTM.Stream = function(data){
this.data = data;
this.offset = 0;
if (typeof data === 'string'){
this.readByte = this.readByteFromString;
this.readString = this.readStringFromString;
} else {
this.readByte = this.readByteFromArray;
this.readString = this.readStringFromArray;
}
};
CTM.Stream.prototype.TWO_POW_MINUS23 = Math.pow(2, -23);
CTM.Stream.prototype.TWO_POW_MINUS126 = Math.pow(2, -126);
CTM.Stream.prototype.readByte = function(){
CTM.Stream.prototype.readByteFromArray = function(){
return this.data[this.offset ++] & 0xff;
};
CTM.Stream.prototype.readByteFromString = function(){
return this.data.charCodeAt(this.offset ++) & 0xff;
};
......@@ -625,7 +636,16 @@ CTM.Stream.prototype.readFloat32 = function(){
return s * 0;
};
CTM.Stream.prototype.readString = function(){
CTM.Stream.prototype.readStringFromArray = function(){
var len = this.readInt32();
this.offset += len;
return this.data.subarray(this.offset - len, len);
};
CTM.Stream.prototype.readStringFromString = function(){
var len = this.readInt32();
this.offset += len;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册