forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
82
Kha/Sources/kha/arrays/ByteArray.hx
Normal file
82
Kha/Sources/kha/arrays/ByteArray.hx
Normal file
@ -0,0 +1,82 @@
|
||||
package kha.arrays;
|
||||
|
||||
/**
|
||||
* Maps a byte array over a byte buffer, allowing for mixed-type access of its contents.
|
||||
* This type unifies with all typed array classes, and vice-versa.
|
||||
*/
|
||||
extern class ByteArray {
|
||||
/**
|
||||
* Underlying byte buffer.
|
||||
*/
|
||||
var buffer(get, null): ByteBuffer;
|
||||
|
||||
/**
|
||||
* Length in bytes of the byte array.
|
||||
*/
|
||||
var byteLength(get, null): Int;
|
||||
|
||||
/**
|
||||
* Byte offset into the underlying byte buffer.
|
||||
*/
|
||||
var byteOffset(get, null): Int;
|
||||
|
||||
/**
|
||||
* Creates a new array over a byte buffer.
|
||||
* @param buffer underlying byte buffer
|
||||
* @param byteOffset offset of the first byte of the array into the byte buffer, defaults to 0
|
||||
* @param byteLength amount of bytes to map, defaults to entire buffer
|
||||
*/
|
||||
function new(buffer: ByteBuffer, ?byteOffset: Int, ?byteLength: Int): Void;
|
||||
|
||||
/**
|
||||
* Creates a new array from scratch.
|
||||
* @param byteLength number of bytes to create
|
||||
* @return ByteArray
|
||||
*/
|
||||
static function make(byteLength: Int): ByteArray;
|
||||
|
||||
function getInt8(byteOffset: Int): Int;
|
||||
function getUint8(byteOffset: Int): Int;
|
||||
function getInt16(byteOffset: Int): Int;
|
||||
function getUint16(byteOffset: Int): Int;
|
||||
function getInt32(byteOffset: Int): Int;
|
||||
function getUint32(byteOffset: Int): Int;
|
||||
function getFloat32(byteOffset: Int): FastFloat;
|
||||
function getFloat64(byteOffset: Int): Float;
|
||||
function setInt8(byteOffset: Int, value: Int): Void;
|
||||
function setUint8(byteOffset: Int, value: Int): Void;
|
||||
function setInt16(byteOffset: Int, value: Int): Void;
|
||||
function setUint16(byteOffset: Int, value: Int): Void;
|
||||
function setInt32(byteOffset: Int, value: Int): Void;
|
||||
function setUint32(byteOffset: Int, value: Int): Void;
|
||||
function setFloat32(byteOffset: Int, value: FastFloat): Void;
|
||||
function setFloat64(byteOffset: Int, value: Float): Void;
|
||||
|
||||
function getInt16LE(byteOffset: Int): Int;
|
||||
function getUint16LE(byteOffset: Int): Int;
|
||||
function getInt32LE(byteOffset: Int): Int;
|
||||
function getUint32LE(byteOffset: Int): Int;
|
||||
function getFloat32LE(byteOffset: Int): FastFloat;
|
||||
function getFloat64LE(byteOffset: Int): Float;
|
||||
function setInt16LE(byteOffset: Int, value: Int): Void;
|
||||
function setUint16LE(byteOffset: Int, value: Int): Void;
|
||||
function setInt32LE(byteOffset: Int, value: Int): Void;
|
||||
function setUint32LE(byteOffset: Int, value: Int): Void;
|
||||
function setFloat32LE(byteOffset: Int, value: FastFloat): Void;
|
||||
function setFloat64LE(byteOffset: Int, value: Float): Void;
|
||||
|
||||
function getInt16BE(byteOffset: Int): Int;
|
||||
function getUint16BE(byteOffset: Int): Int;
|
||||
function getInt32BE(byteOffset: Int): Int;
|
||||
function getUint32BE(byteOffset: Int): Int;
|
||||
function getFloat32BE(byteOffset: Int): FastFloat;
|
||||
function getFloat64BE(byteOffset: Int): Float;
|
||||
function setInt16BE(byteOffset: Int, value: Int): Void;
|
||||
function setUint16BE(byteOffset: Int, value: Int): Void;
|
||||
function setInt32BE(byteOffset: Int, value: Int): Void;
|
||||
function setUint32BE(byteOffset: Int, value: Int): Void;
|
||||
function setFloat32BE(byteOffset: Int, value: FastFloat): Void;
|
||||
function setFloat64BE(byteOffset: Int, value: Float): Void;
|
||||
|
||||
function subarray(start: Int, ?end: Int): ByteArray;
|
||||
}
|
18
Kha/Sources/kha/arrays/ByteBuffer.hx
Normal file
18
Kha/Sources/kha/arrays/ByteBuffer.hx
Normal file
@ -0,0 +1,18 @@
|
||||
package kha.arrays;
|
||||
|
||||
/**
|
||||
* Holds unformatted binary data into a byte buffer. Use ByteArray for access.
|
||||
*/
|
||||
extern class ByteBuffer {
|
||||
public static function create(length: Int): ByteBuffer;
|
||||
|
||||
public var byteLength(get, null): Int;
|
||||
|
||||
/**
|
||||
* Returns a shallow copy of a range of bytes from this buffer.
|
||||
* @param begin start of the range, inclusive
|
||||
* @param end end of the range, exclusive
|
||||
* @return ByteBuffer
|
||||
*/
|
||||
public function slice(begin: Int, end: Int): ByteBuffer;
|
||||
}
|
29
Kha/Sources/kha/arrays/Float32Array.hx
Normal file
29
Kha/Sources/kha/arrays/Float32Array.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package kha.arrays;
|
||||
|
||||
@:forward
|
||||
abstract Float32Array(ByteArray) from ByteArray to ByteArray {
|
||||
public var length(get, never): Int;
|
||||
|
||||
inline function get_length(): Int {
|
||||
return this.byteLength >> 2;
|
||||
}
|
||||
|
||||
public function new(elements: Int) {
|
||||
this = ByteArray.make(elements * 4);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function get(k: Int): FastFloat {
|
||||
return this.getFloat32(k * 4);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function set(k: Int, v: FastFloat): FastFloat {
|
||||
this.setFloat32(k * 4, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
public inline function subarray(start: Int, ?end: Int): Float32Array {
|
||||
return this.subarray(start * 4, end != null ? end * 4 : end);
|
||||
}
|
||||
}
|
29
Kha/Sources/kha/arrays/Float64Array.hx
Normal file
29
Kha/Sources/kha/arrays/Float64Array.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package kha.arrays;
|
||||
|
||||
@:forward
|
||||
abstract Float64Array(ByteArray) from ByteArray to ByteArray {
|
||||
public var length(get, never): Int;
|
||||
|
||||
inline function get_length(): Int {
|
||||
return this.byteLength >> 3;
|
||||
}
|
||||
|
||||
public function new(elements: Int) {
|
||||
this = ByteArray.make(elements * 8);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function get(k: Int): Float {
|
||||
return this.getFloat64(k * 8);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function set(k: Int, v: Float): Float {
|
||||
this.setFloat64(k * 8, v);
|
||||
return v;
|
||||
}
|
||||
|
||||
public inline function subarray(start: Int, ?end: Int): Float64Array {
|
||||
return this.subarray(start * 8, end != null ? end * 8 : end);
|
||||
}
|
||||
}
|
29
Kha/Sources/kha/arrays/Int16Array.hx
Normal file
29
Kha/Sources/kha/arrays/Int16Array.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package kha.arrays;
|
||||
|
||||
@:forward
|
||||
abstract Int16Array(ByteArray) from ByteArray to ByteArray {
|
||||
public var length(get, never): Int;
|
||||
|
||||
inline function get_length(): Int {
|
||||
return this.byteLength >> 1;
|
||||
}
|
||||
|
||||
public function new(elements: Int) {
|
||||
this = ByteArray.make(elements * 2);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function get(k: Int): Int {
|
||||
return this.getInt16(k * 2);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function set(k: Int, v: Int): Int {
|
||||
this.setInt16(k * 2, v);
|
||||
return get(k);
|
||||
}
|
||||
|
||||
public inline function subarray(start: Int, ?end: Int): Int16Array {
|
||||
return this.subarray(start * 2, end != null ? end * 2 : null);
|
||||
}
|
||||
}
|
29
Kha/Sources/kha/arrays/Int32Array.hx
Normal file
29
Kha/Sources/kha/arrays/Int32Array.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package kha.arrays;
|
||||
|
||||
@:forward
|
||||
abstract Int32Array(ByteArray) from ByteArray to ByteArray {
|
||||
public var length(get, never): Int;
|
||||
|
||||
inline function get_length(): Int {
|
||||
return this.byteLength >> 2;
|
||||
}
|
||||
|
||||
public function new(elements: Int) {
|
||||
this = ByteArray.make(elements * 4);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function get(k: Int): Int {
|
||||
return this.getInt32(k * 4);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function set(k: Int, v: Int): Int {
|
||||
this.setInt32(k * 4, v);
|
||||
return get(k);
|
||||
}
|
||||
|
||||
public inline function subarray(start: Int, ?end: Int): Int32Array {
|
||||
return this.subarray(start * 4, end != null ? end * 4 : null);
|
||||
}
|
||||
}
|
29
Kha/Sources/kha/arrays/Int8Array.hx
Normal file
29
Kha/Sources/kha/arrays/Int8Array.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package kha.arrays;
|
||||
|
||||
@:forward
|
||||
abstract Int8Array(ByteArray) from ByteArray to ByteArray {
|
||||
public var length(get, never): Int;
|
||||
|
||||
inline function get_length(): Int {
|
||||
return this.byteLength;
|
||||
}
|
||||
|
||||
public function new(elements: Int) {
|
||||
this = ByteArray.make(elements);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function get(k: Int): Int {
|
||||
return this.getInt8(k);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function set(k: Int, v: Int): Int {
|
||||
this.setInt8(k, v);
|
||||
return get(k);
|
||||
}
|
||||
|
||||
public inline function subarray(start: Int, ?end: Int): Int8Array {
|
||||
return this.subarray(start, end);
|
||||
}
|
||||
}
|
29
Kha/Sources/kha/arrays/Uint16Array.hx
Normal file
29
Kha/Sources/kha/arrays/Uint16Array.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package kha.arrays;
|
||||
|
||||
@:forward
|
||||
abstract Uint16Array(ByteArray) from ByteArray to ByteArray {
|
||||
public var length(get, never): Int;
|
||||
|
||||
inline function get_length(): Int {
|
||||
return this.byteLength >> 1;
|
||||
}
|
||||
|
||||
public function new(elements: Int) {
|
||||
this = ByteArray.make(elements * 2);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function get(k: Int): Int {
|
||||
return this.getUint16(k * 2);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function set(k: Int, v: Int): Int {
|
||||
this.setUint16(k * 2, v);
|
||||
return get(k);
|
||||
}
|
||||
|
||||
public inline function subarray(start: Int, ?end: Int): Uint16Array {
|
||||
return this.subarray(start * 2, end != null ? end * 2 : null);
|
||||
}
|
||||
}
|
29
Kha/Sources/kha/arrays/Uint32Array.hx
Normal file
29
Kha/Sources/kha/arrays/Uint32Array.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package kha.arrays;
|
||||
|
||||
@:forward
|
||||
abstract Uint32Array(ByteArray) from ByteArray to ByteArray {
|
||||
public var length(get, never): Int;
|
||||
|
||||
inline function get_length(): Int {
|
||||
return this.byteLength >> 2;
|
||||
}
|
||||
|
||||
public function new(elements: Int) {
|
||||
this = ByteArray.make(elements * 4);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function get(k: Int): Int {
|
||||
return this.getUint32(k * 4);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function set(k: Int, v: Int): Int {
|
||||
this.setUint32(k * 4, v);
|
||||
return get(k);
|
||||
}
|
||||
|
||||
public inline function subarray(start: Int, ?end: Int): Uint32Array {
|
||||
return this.subarray(start * 4, end != null ? end * 4 : null);
|
||||
}
|
||||
}
|
29
Kha/Sources/kha/arrays/Uint8Array.hx
Normal file
29
Kha/Sources/kha/arrays/Uint8Array.hx
Normal file
@ -0,0 +1,29 @@
|
||||
package kha.arrays;
|
||||
|
||||
@:forward
|
||||
abstract Uint8Array(ByteArray) from ByteArray to ByteArray {
|
||||
public var length(get, never): Int;
|
||||
|
||||
inline function get_length(): Int {
|
||||
return this.byteLength;
|
||||
}
|
||||
|
||||
public function new(elements: Int) {
|
||||
this = ByteArray.make(elements);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function get(k: Int): Int {
|
||||
return this.getUint8(k);
|
||||
}
|
||||
|
||||
@:arrayAccess
|
||||
public inline function set(k: Int, v: Int): Int {
|
||||
this.setUint8(k, v);
|
||||
return get(k);
|
||||
}
|
||||
|
||||
public inline function subarray(start: Int, ?end: Int): Uint8Array {
|
||||
return this.subarray(start, end);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user