Support for saving compiled AngelScript to either file or RAM, so we can reuse it.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2020-04-11 14:42:49 +02:00
parent 0b045db811
commit bf36103c11
6 changed files with 228 additions and 15 deletions

View File

@@ -0,0 +1,25 @@
#ifndef PKMNLIB_FILEBYTECODESTREAM_HPP
#define PKMNLIB_FILEBYTECODESTREAM_HPP
#include <angelscript.h>
#include <cstdio>
class FileByteCodeStream : public asIBinaryStream {
private:
FILE* _file;
public:
explicit FileByteCodeStream(FILE* file) : _file(file) {}
int Write(const void* ptr, asUINT size) {
if (size == 0)
return 0;
return fwrite(ptr, size, 1, _file);
}
int Read(void* ptr, asUINT size) {
if (size == 0)
return 0;
return fread(ptr, size, 1, _file);
}
};
#endif // PKMNLIB_FILEBYTECODESTREAM_HPP