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
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user