Add ScriptingObjectReference for Read/WriteStream and scripting interop as an array

This commit is contained in:
Wojciech Figat
2022-11-09 10:48:22 +01:00
parent c41d67c4ac
commit c0f596a00e
4 changed files with 53 additions and 11 deletions

View File

@@ -5,10 +5,6 @@
#include "Stream.h"
#include "Engine/Core/Templates.h"
struct CommonValue;
struct Variant;
struct VariantType;
class ISerializable;
extern FLAXENGINE_API class ScriptingObject* FindObject(const Guid& id, class MClass* type);
/// <summary>
@@ -156,6 +152,14 @@ public:
data = (T*)::FindObject(*(Guid*)id, T::GetStaticClass());
}
template<typename T>
FORCE_INLINE void Read(ScriptingObjectReference<T>& v)
{
T* ptr;
Read(ptr);
v = ptr;
}
/// <summary>
/// Read data array
/// </summary>

View File

@@ -8,9 +8,15 @@
#define FILESTREAM_BUFFER_SIZE 4096
#define STREAM_MAX_STRING_LENGTH (4*1024) // 4 kB
// Forward declarations
class ReadStream;
class WriteStream;
struct CommonValue;
struct Variant;
struct VariantType;
class ISerializable;
class ScriptingObject;
template<typename T>
class ScriptingObjectReference;
/// <summary>
/// Base class for all data streams (memory streams, file streams etc.)

View File

@@ -5,12 +5,6 @@
#include "Stream.h"
#include "Engine/Core/Templates.h"
struct CommonValue;
struct Variant;
struct VariantType;
class ISerializable;
class ScriptingObject;
/// <summary>
/// Base class for all data write streams
/// </summary>
@@ -177,6 +171,12 @@ public:
WriteBytes(id, sizeof(id));
}
template<typename T>
FORCE_INLINE void Write(const ScriptingObjectReference<T>& v)
{
Write(v.Get());
}
template<typename T, typename AllocationType = HeapAllocation>
void Write(const Array<T, AllocationType>& data)
{