// Class: lime.utils._DataPointer.DataPointer_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_DataPointerObject() {return require("./../../../lime/utils/DataPointerObject");}
function Std() {return require("./../../../Std");}
function Type() {return require("./../../../Type");}
function lime_system__$CFFIPointer_CFFIPointer_$Impl_$() {return require("./../../../lime/system/_CFFIPointer/CFFIPointer_Impl_");}

// Constructor

var DataPointer_Impl_ = function(){}

// Meta

DataPointer_Impl_.__name__ = ["lime","utils","_DataPointer","DataPointer_Impl_"];
DataPointer_Impl_.prototype = {
	
};
DataPointer_Impl_.prototype.__class__ = DataPointer_Impl_.prototype.constructor = $hxClasses["lime.utils._DataPointer.DataPointer_Impl_"] = DataPointer_Impl_;

// Init



// Statics

DataPointer_Impl_._new = function(data) {
	var this1 = data;
	return this1;
}
DataPointer_Impl_.fromInt = function(value) {
	return DataPointer_Impl_._new(new (lime_utils_DataPointerObject().default)(null,null,value));
}
DataPointer_Impl_.fromFloat = function(value) {
	return DataPointer_Impl_._new(new (lime_utils_DataPointerObject().default)(null,null,(Std().default)["int"](value)));
}
DataPointer_Impl_.fromBytesPointer = function(pointer) {
	return DataPointer_Impl_._new(new (lime_utils_DataPointerObject().default)(null,pointer.bytes.getData(),pointer.offset));
}
DataPointer_Impl_.fromArrayBufferView = function(arrayBufferView) {
	return DataPointer_Impl_._new(new (lime_utils_DataPointerObject().default)(arrayBufferView));
}
DataPointer_Impl_.fromArrayBuffer = function(buffer) {
	return DataPointer_Impl_._new(new (lime_utils_DataPointerObject().default)(null,buffer));
}
DataPointer_Impl_.fromBytes = function(bytes) {
	return DataPointer_Impl_.fromArrayBuffer(bytes.getData());
}
DataPointer_Impl_.fromBytesData = function(bytesData) {
	return DataPointer_Impl_.fromArrayBuffer(bytesData);
}
DataPointer_Impl_.fromLimeBytes = function(bytes) {
	return DataPointer_Impl_.fromBytes(bytes);
}
DataPointer_Impl_.fromCFFIPointer = function(pointer) {
	return null;
}
DataPointer_Impl_.fromFile = function(path) {
	return null;
}
DataPointer_Impl_.toBufferOrBufferView = function(this1,length) {
	var data = this1;
	if (!data) return null;
	var _g = data.type;
	switch((Type().default).enumIndex(_g)) {
	case 0:
		if(length == null) {
			length = data.buffer.byteLength;
		}
		if(data.offset == 0 && length == data.buffer.byteLength) {
			return data.buffer;
		} else {
			var buffer = data.buffer;
			var byteoffset = data.offset;
			var this2;
			if(buffer != null) {
				if(length == null) {
					this2 = new Uint8Array(buffer,byteoffset);
				} else {
					this2 = new Uint8Array(buffer,byteoffset,length);
				}
			} else {
				this2 = null;
			}
			return this2;
		}
		break;
	case 1:
		if(length == null) {
			length = data.bufferView.byteLength;
		}
		if(data.offset == 0 && length == data.bufferView.byteLength) {
			return data.bufferView;
		} else {
			var buffer1 = data.bufferView.buffer;
			var byteoffset1 = data.bufferView.byteOffset + data.offset;
			var this3;
			if(buffer1 != null) {
				if(length == null) {
					this3 = new Uint8Array(buffer1,byteoffset1);
				} else {
					this3 = new Uint8Array(buffer1,byteoffset1,length);
				}
			} else {
				this3 = null;
			}
			return this3;
		}
		break;
	default:
		return null;
	}
}
DataPointer_Impl_.toBufferView = function(this1,length) {
	var data = this1;
	if (!data) return null;
	var _g = data.type;
	switch((Type().default).enumIndex(_g)) {
	case 0:
		if(length == null) {
			length = data.buffer.byteLength;
		}
		var buffer = data.buffer;
		var byteoffset = data.offset;
		var this2;
		if(buffer != null) {
			if(length == null) {
				this2 = new Uint8Array(buffer,byteoffset);
			} else {
				this2 = new Uint8Array(buffer,byteoffset,length);
			}
		} else {
			this2 = null;
		}
		return this2;
	case 1:
		if(length == null) {
			length = data.bufferView.byteLength;
		}
		if(data.offset == 0 && length == data.bufferView.byteLength) {
			return data.bufferView;
		} else {
			var buffer1 = data.bufferView.buffer;
			var byteoffset1 = data.bufferView.byteOffset + data.offset;
			var this3;
			if(buffer1 != null) {
				if(length == null) {
					this3 = new Uint8Array(buffer1,byteoffset1);
				} else {
					this3 = new Uint8Array(buffer1,byteoffset1,length);
				}
			} else {
				this3 = null;
			}
			return this3;
		}
		break;
	default:
		return null;
	}
}
DataPointer_Impl_.toFloat32Array = function(this1,length) {
	var data = this1;
	if (!data) return null;
	var _g = data.type;
	switch((Type().default).enumIndex(_g)) {
	case 0:
		if(length == null) {
			length = data.buffer.byteLength;
		}
		var buffer = data.buffer;
		var byteoffset = data.offset;
		var len = (Std().default)["int"](length / 4);
		var this2;
		if(buffer != null) {
			if(len == null) {
				this2 = new Float32Array(buffer,byteoffset);
			} else {
				this2 = new Float32Array(buffer,byteoffset,len);
			}
		} else {
			this2 = null;
		}
		return this2;
	case 1:
		if(length == null) {
			length = data.bufferView.byteLength;
		}
		if(data.offset == 0 && length == data.bufferView.byteLength && data.bufferView.constructor == Float32Array) {
			return data.bufferView;
		} else {
			if(length > data.bufferView.byteLength) {
				length = data.bufferView.byteLength;
			}
			var buffer1 = data.bufferView.buffer;
			var byteoffset1 = data.bufferView.byteOffset + data.offset;
			var len1 = (Std().default)["int"](length / 4);
			var this3;
			if(buffer1 != null) {
				if(len1 == null) {
					this3 = new Float32Array(buffer1,byteoffset1);
				} else {
					this3 = new Float32Array(buffer1,byteoffset1,len1);
				}
			} else {
				this3 = null;
			}
			return this3;
		}
		break;
	default:
		return null;
	}
}
DataPointer_Impl_.toInt32Array = function(this1,length) {
	var data = this1;
	if (!data) return null;
	var _g = data.type;
	switch((Type().default).enumIndex(_g)) {
	case 0:
		if(length == null) {
			length = data.buffer.byteLength;
		}
		var buffer = data.buffer;
		var byteoffset = data.offset;
		var len = (Std().default)["int"](length / 4);
		var this2;
		if(buffer != null) {
			if(len == null) {
				this2 = new Int32Array(buffer,byteoffset);
			} else {
				this2 = new Int32Array(buffer,byteoffset,len);
			}
		} else {
			this2 = null;
		}
		return this2;
	case 1:
		if(length == null) {
			length = data.bufferView.byteLength;
		}
		if(data.offset == 0 && length == data.bufferView.byteLength && data.bufferView.constructor == Int32Array) {
			return data.bufferView;
		} else {
			var buffer1 = data.bufferView.buffer;
			var byteoffset1 = data.bufferView.byteOffset + data.offset;
			var len1 = (Std().default)["int"](length / 4);
			var this3;
			if(buffer1 != null) {
				if(len1 == null) {
					this3 = new Int32Array(buffer1,byteoffset1);
				} else {
					this3 = new Int32Array(buffer1,byteoffset1,len1);
				}
			} else {
				this3 = null;
			}
			return this3;
		}
		break;
	default:
		return null;
	}
}
DataPointer_Impl_.toUInt8Array = function(this1,length) {
	var data = this1;
	if (!data) return null;
	var _g = data.type;
	switch((Type().default).enumIndex(_g)) {
	case 0:
		if(length == null) {
			length = data.buffer.byteLength;
		}
		var buffer = data.buffer;
		var byteoffset = data.offset;
		var this2;
		if(buffer != null) {
			if(length == null) {
				this2 = new Uint8Array(buffer,byteoffset);
			} else {
				this2 = new Uint8Array(buffer,byteoffset,length);
			}
		} else {
			this2 = null;
		}
		return this2;
	case 1:
		if(length == null) {
			length = data.bufferView.byteLength;
		}
		if(data.offset == 0 && length == data.bufferView.byteLength && data.bufferView.constructor == Uint8Array) {
			return data.bufferView;
		} else {
			var buffer1 = data.bufferView.buffer;
			var byteoffset1 = data.bufferView.byteOffset + data.offset;
			var this3;
			if(buffer1 != null) {
				if(length == null) {
					this3 = new Uint8Array(buffer1,byteoffset1);
				} else {
					this3 = new Uint8Array(buffer1,byteoffset1,length);
				}
			} else {
				this3 = null;
			}
			return this3;
		}
		break;
	default:
		return null;
	}
}
DataPointer_Impl_.toUInt32Array = function(this1,length) {
	var data = this1;
	if (!data) return null;
	var _g = data.type;
	switch((Type().default).enumIndex(_g)) {
	case 0:
		if(length == null) {
			length = data.buffer.byteLength;
		}
		var buffer = data.buffer;
		var byteoffset = data.offset;
		var len = (Std().default)["int"](length / 4);
		var this2;
		if(buffer != null) {
			if(len == null) {
				this2 = new Uint32Array(buffer,byteoffset);
			} else {
				this2 = new Uint32Array(buffer,byteoffset,len);
			}
		} else {
			this2 = null;
		}
		return this2;
	case 1:
		if(length == null) {
			length = data.bufferView.byteLength;
		}
		if(data.offset == 0 && length == data.bufferView.byteLength && data.bufferView.constructor == Uint32Array) {
			return data.bufferView;
		} else {
			var buffer1 = data.bufferView.buffer;
			var byteoffset1 = data.bufferView.byteOffset + data.offset;
			var len1 = (Std().default)["int"](length / 4);
			var this3;
			if(buffer1 != null) {
				if(len1 == null) {
					this3 = new Uint32Array(buffer1,byteoffset1);
				} else {
					this3 = new Uint32Array(buffer1,byteoffset1,len1);
				}
			} else {
				this3 = null;
			}
			return this3;
		}
		break;
	default:
		return null;
	}
}
DataPointer_Impl_.toValue = function(this1) {
	var data = this1;
	if (!data) return 0;
	if (typeof data === 'number') return data;
	var _g = data.type;
	if((Type().default).enumIndex(_g) == 2) {
		return data.offset;
	} else {
		return 0;
	}
}
DataPointer_Impl_.__withOffset = function(data,offset) {
	return null;
}
DataPointer_Impl_.equals = function(a,b) {
	return a == b;
}
DataPointer_Impl_.equalsPointer = function(a,b) {
	return a == b;
}
DataPointer_Impl_.greaterThan = function(a,b) {
	return a > b;
}
DataPointer_Impl_.greaterThanPointer = function(a,b) {
	return (lime_system__$CFFIPointer_CFFIPointer_$Impl_$().default).get(a) > (lime_system__$CFFIPointer_CFFIPointer_$Impl_$().default).get(b);
}
DataPointer_Impl_.greaterThanOrEqual = function(a,b) {
	return a >= b;
}
DataPointer_Impl_.greaterThanOrEqualPointer = function(a,b) {
	return (lime_system__$CFFIPointer_CFFIPointer_$Impl_$().default).get(a) >= (lime_system__$CFFIPointer_CFFIPointer_$Impl_$().default).get(b);
}
DataPointer_Impl_.lessThan = function(a,b) {
	return a < b;
}
DataPointer_Impl_.lessThanPointer = function(a,b) {
	return (lime_system__$CFFIPointer_CFFIPointer_$Impl_$().default).get(a) < (lime_system__$CFFIPointer_CFFIPointer_$Impl_$().default).get(b);
}
DataPointer_Impl_.lessThanOrEqual = function(a,b) {
	return a <= b;
}
DataPointer_Impl_.lessThanOrEqualPointer = function(a,b) {
	return (lime_system__$CFFIPointer_CFFIPointer_$Impl_$().default).get(a) <= (lime_system__$CFFIPointer_CFFIPointer_$Impl_$().default).get(b);
}
DataPointer_Impl_.notEquals = function(a,b) {
	return a != b;
}
DataPointer_Impl_.notEqualsPointer = function(a,b) {
	return a != b;
}
DataPointer_Impl_.plus = function(a,b) {
	return DataPointer_Impl_.__withOffset(a,b);
}
DataPointer_Impl_.plusPointer = function(a,b) {
	return DataPointer_Impl_.__withOffset(a,(Std().default)["int"](b));
}
DataPointer_Impl_.minus = function(a,b) {
	return DataPointer_Impl_.__withOffset(a,-b);
}
DataPointer_Impl_.minusPointer = function(a,b) {
	return DataPointer_Impl_.__withOffset(a,-(Std().default)["int"](b));
}


// Export

exports.default = DataPointer_Impl_;