First pass at refactoring native CFFI Bytes

This commit is contained in:
Joshua Granick
2018-06-15 23:21:03 -07:00
parent ecd7876c4b
commit 6d666b0eeb
29 changed files with 441 additions and 988 deletions

View File

@@ -9,47 +9,24 @@
namespace lime {
struct HL_ArrayBufferView {
struct ArrayBufferView {
hl_type* t;
/*TypedArrayType*/ int type;
HL_Bytes* buffer;
Bytes* buffer;
int byteOffset;
int byteLength;
int length;
int bytesPerElement;
};
class ArrayBufferView {
public:
ArrayBufferView ();
ArrayBufferView (int size);
ArrayBufferView (value arrayBufferView);
ArrayBufferView (HL_ArrayBufferView* arrayBufferView);
~ArrayBufferView ();
unsigned char* Data ();
const unsigned char* Data () const;
int Length () const;
void Resize (int size);
void Set (value bytes);
void Set (const QuickVec<unsigned char> data);
value Value ();
Bytes* buffer;
int byteLength;
int length;
private:
HL_ArrayBufferView* _bufferView;
value _value;
ArrayBufferView (value arrayBufferView);
~ArrayBufferView ();
void Resize (int size);
void Set (value bytes);
void Set (const QuickVec<unsigned char> data);
value Value ();
value Value (value arrayBufferView);
};

View File

@@ -9,41 +9,22 @@
namespace lime {
struct HL_Bytes {
struct Bytes {
hl_type* t;
int length;
unsigned char* b;
};
struct Bytes {
Bytes ();
Bytes (int size);
Bytes (value bytes);
Bytes (HL_Bytes* bytes);
Bytes (const char* path);
Bytes (const QuickVec<unsigned char> data);
~Bytes ();
unsigned char* Data ();
const unsigned char* Data () const;
int Length () const;
void ReadFile (const char* path);
void Resize (int size);
void Set (value bytes);
void Set (HL_Bytes* bytes);
void Set (const QuickVec<unsigned char> data);
void* Value ();
HL_Bytes* _bytes;
unsigned char* _data;
int _length;
value _value;
value Value (value bytes);
value Value ();
};

View File

@@ -18,7 +18,7 @@ namespace lime {
Resource (HL_String* path) : data (NULL), path (path ? hl_to_utf8 ((const uchar*)path->bytes) : NULL) {}
Resource (Bytes* data) : data (data), path (NULL) {}
Bytes *data;
Bytes* data;
const char* path;