// Class: openfl.utils._ByteArray.ByteArray_Impl_

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 $import = require("./../../../import_stub").default;
function lime_utils_BytePointerData() {return require("./../../../lime/utils/BytePointerData");}
function openfl_utils_ByteArrayData() {return require("./../../../openfl/utils/ByteArrayData");}
function haxe_io_Bytes() {return require("./../../../haxe/io/Bytes");}
function Std() {return require("./../../../Std");}
function lime_utils__$Bytes_Bytes_$Impl_$() {return require("./../../../lime/utils/_Bytes/Bytes_Impl_");}
function lime_app_Future() {return require("./../../../lime/app/Future");}
function lime_utils__$BytePointer_BytePointer_$Impl_$() {return require("./../../../lime/utils/_BytePointer/BytePointer_Impl_");}

// Constructor

var ByteArray_Impl_ = function(){}

// Meta

ByteArray_Impl_.__name__ = ["openfl","utils","_ByteArray","ByteArray_Impl_"];
ByteArray_Impl_.prototype = {
	
};
ByteArray_Impl_.prototype.__class__ = $hxClasses["openfl.utils._ByteArray.ByteArray_Impl_"] = ByteArray_Impl_;

// Init



// Statics

ByteArray_Impl_._new = function(length) {
	if(length == null) {
		length = 0;
	}
	var this1 = new (openfl_utils_ByteArrayData().default)(length);
	return this1;
}
ByteArray_Impl_.get = function(this1,index) {
	return this1.get(index);
}
ByteArray_Impl_.set = function(this1,index,value) {
	this1.__resize(index + 1);
	this1.set(index,value);
	return value;
}
ByteArray_Impl_.fromArrayBuffer = function(buffer) {
	if(buffer == null) {
		return null;
	}
	return (openfl_utils_ByteArrayData().default).fromBytes((haxe_io_Bytes().default).ofData(buffer));
}
ByteArray_Impl_.fromBytes = function(bytes) {
	if(bytes == null) {
		return null;
	}
	if((Std().default)["is"](bytes,(openfl_utils_ByteArrayData().default))) {
		return bytes;
	} else {
		return (openfl_utils_ByteArrayData().default).fromBytes(bytes);
	}
}
ByteArray_Impl_.fromBytesData = function(bytesData) {
	if(bytesData == null) {
		return null;
	}
	return (openfl_utils_ByteArrayData().default).fromBytes((haxe_io_Bytes().default).ofData(bytesData));
}
ByteArray_Impl_.fromFile = function(path) {
	return ByteArray_Impl_.fromBytes((lime_utils__$Bytes_Bytes_$Impl_$().default).fromFile(path));
}
ByteArray_Impl_.loadFromBytes = function(bytes) {
	return (lime_utils__$Bytes_Bytes_$Impl_$().default).loadFromBytes(bytes).then(function(limeBytes) {
		var byteArray = ByteArray_Impl_.fromBytes(limeBytes);
		return (lime_app_Future().default).withValue(byteArray);
	});
}
ByteArray_Impl_.loadFromFile = function(path) {
	return (lime_utils__$Bytes_Bytes_$Impl_$().default).loadFromFile(path).then(function(limeBytes) {
		var byteArray = ByteArray_Impl_.fromBytes(limeBytes);
		return (lime_app_Future().default).withValue(byteArray);
	});
}
ByteArray_Impl_.fromLimeBytes = function(bytes) {
	return ByteArray_Impl_.fromBytes(bytes);
}
ByteArray_Impl_.toArrayBuffer = function(byteArray) {
	return byteArray.getData();
}
ByteArray_Impl_.toBytePointer = function(byteArray) {
	(lime_utils__$BytePointer_BytePointer_$Impl_$().default).set(ByteArray_Impl_.__bytePointer,byteArray,null,null,byteArray.position);
	return ByteArray_Impl_.__bytePointer;
}
ByteArray_Impl_.toBytes = function(byteArray) {
	return byteArray;
}
ByteArray_Impl_.toBytesData = function(byteArray) {
	return byteArray.getData();
}
ByteArray_Impl_.toLimeBytes = function(byteArray) {
	return ByteArray_Impl_.toBytes(ByteArray_Impl_.fromBytes(ByteArray_Impl_.toBytes(byteArray)));
}
ByteArray_Impl_.get_length = function(this1) {
	if(this1 == null) {
		return 0;
	} else {
		return this1.l;
	}
}
ByteArray_Impl_.set_length = function(this1,value) {
	this1.set_length(value);
	return value;
}
ByteArray_Impl_.defaultObjectEncoding = 10
ByteArray_Impl_.__bytePointer = (function($this) {
	var $r;
	var this1 = new (lime_utils_BytePointerData().default)(null,0);
	$r = this1;
	return $r;
}(this))

// Export

exports.default = ByteArray_Impl_;