Rework of ScriptResolver to binary handling. Now also serialises the type database to the stream, simplifying it's api.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
#include <angelscript.h>
|
||||
#include <vector>
|
||||
|
||||
class MemoryByteCodeStream : public asIBinaryStream {
|
||||
class MemoryByteCodeStream : public IPkmnBinaryStream {
|
||||
private:
|
||||
uint8_t* _out;
|
||||
size_t _index = 0;
|
||||
@@ -13,12 +13,15 @@ private:
|
||||
#define MEM_STEPS 256
|
||||
|
||||
public:
|
||||
MemoryByteCodeStream() : _out((uint8_t*)malloc(MEM_STEPS * sizeof(uint8_t))), _capacity(MEM_STEPS){};
|
||||
MemoryByteCodeStream(uint8_t* in, size_t size) : _out(in), _size(size) {}
|
||||
MemoryByteCodeStream()
|
||||
: IPkmnBinaryStream(SIZE_MAX), _out((uint8_t*)malloc(MEM_STEPS * sizeof(uint8_t))), _capacity(MEM_STEPS){};
|
||||
MemoryByteCodeStream(uint8_t* in, size_t size) : IPkmnBinaryStream(SIZE_MAX), _out(in), _size(size) {}
|
||||
|
||||
uint8_t* GetOut() const { return _out; }
|
||||
size_t GetWrittenSize() const { return _size; }
|
||||
|
||||
void SetAngelScriptBound(size_t bound) noexcept { _angelScriptBound = bound; }
|
||||
|
||||
int Write(const void* ptr, asUINT size) final {
|
||||
if (size == 0)
|
||||
return 0;
|
||||
@@ -38,6 +41,14 @@ public:
|
||||
_size += size;
|
||||
return size;
|
||||
}
|
||||
|
||||
void WriteToPosition(const void* ptr, asUINT size, size_t position) {
|
||||
auto start = reinterpret_cast<const uint8_t*>(ptr);
|
||||
for (asUINT index = 0; index < size; index++) {
|
||||
_out[position + index] = *(start + index);
|
||||
}
|
||||
}
|
||||
|
||||
int Read(void* ptr, asUINT size) final {
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user