openfl
Version:
A fast, productive library for 2D cross-platform development.
136 lines (118 loc) • 4.06 kB
JavaScript
// Class: openfl.utils._internal.format.amf3.AMF3ReaderInput
var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this
$global.Object.defineProperty(exports, "__esModule", {value: true});
var __map_reserved = {};
// Imports
var $hxClasses = require("./../../../../../hxClasses_stub").default;
var $hxEnums = require("./../../../../../hxEnums_stub").default;
var $import = require("./../../../../../import_stub").default;
function openfl_utils_IDataInput() {return require("./../../../../../openfl/utils/IDataInput");}
function openfl_utils__$ByteArray_ByteArray_$Impl_$() {return require("./../../../../../openfl/utils/_ByteArray/ByteArray_Impl_");}
function openfl_utils__$internal_format_amf_AMFReader() {return require("./../../../../../openfl/utils/_internal/format/amf/AMFReader");}
function openfl_utils__$internal_format_amf_AMFTools() {return require("./../../../../../openfl/utils/_internal/format/amf/AMFTools");}
function openfl_utils__$internal_format_amf3_AMF3Reader() {return require("./../../../../../openfl/utils/_internal/format/amf3/AMF3Reader");}
function openfl_utils__$internal_format_amf3_AMF3Tools() {return require("./../../../../../openfl/utils/_internal/format/amf3/AMF3Tools");}
// Constructor
var AMF3ReaderInput = function(r) {
this.i = r.i;
this.r = r;
this.objectEncoding = 3;
}
// Meta
AMF3ReaderInput.__name__ = "openfl.utils._internal.format.amf3.AMF3ReaderInput";
AMF3ReaderInput.__isInterface__ = false;
AMF3ReaderInput.__interfaces__ = [(openfl_utils_IDataInput().default)];
AMF3ReaderInput.prototype = {
readBoolean: function() {
return this.i.readByte() != 0;
},
readByte: function() {
return this.i.readByte();
},
readBytes: function(bytes,offset,length) {
if(length == null) {
length = 0;
}
if(offset == null) {
offset = 0;
}
this.i.readBytes((openfl_utils__$ByteArray_ByteArray_$Impl_$().default).toBytes(bytes),offset,length);
},
readDouble: function() {
return this.i.readDouble();
},
readFloat: function() {
return this.i.readFloat();
},
readInt: function() {
return this.i.readInt32();
},
readMultiByte: function(length,charSet) {
return this.i.readString(length);
},
readObject: function() {
switch(this.objectEncoding) {
case 0:
var reader = new (openfl_utils__$internal_format_amf_AMFReader().default)(this.i);
var data = (openfl_utils__$internal_format_amf_AMFTools().default).unwrapValue(reader.read());
return data;
case 3:
var reader1 = new (openfl_utils__$internal_format_amf3_AMF3Reader().default)(this.i,this.r);
var data1 = (openfl_utils__$internal_format_amf3_AMF3Tools().default).decode(reader1.read());
return data1;
default:
return null;
}
},
readShort: function() {
return this.i.readInt16();
},
readUnsignedByte: function() {
return this.i.readByte();
},
readUnsignedInt: function() {
var ch1 = this.i.readByte();
var ch2 = this.i.readByte();
var ch3 = this.i.readByte();
var ch4 = this.i.readByte();
if(this.get_endian() == "littleEndian") {
return ch4 << 24 | ch3 << 16 | ch2 << 8 | ch1;
} else {
return ch1 << 24 | ch2 << 16 | ch3 << 8 | ch4;
}
},
readUnsignedShort: function() {
var ch1 = this.i.readByte();
var ch2 = this.i.readByte();
if(this.get_endian() == "littleEndian") {
return (ch2 << 8) + ch1;
} else {
return ch1 << 8 | ch2;
}
},
readUTF: function() {
var bytesCount = this.readUnsignedShort();
return this.readUTFBytes(bytesCount);
},
readUTFBytes: function(length) {
return this.i.readString(length);
},
get_bytesAvailable: function() {
return -1;
},
get_endian: function() {
if(this.i.bigEndian) {
return "bigEndian";
} else {
return "littleEndian";
}
},
set_endian: function(value) {
return value;
}
};
AMF3ReaderInput.prototype.__class__ = AMF3ReaderInput.prototype.constructor = $hxClasses["openfl.utils._internal.format.amf3.AMF3ReaderInput"] = AMF3ReaderInput;
// Init
// Statics
// Export
exports.default = AMF3ReaderInput;