Refactor Plugins system to support plugins in C++ scripts

This commit is contained in:
Wojtek Figat
2022-07-28 21:05:03 +02:00
parent 6f35b27c29
commit bdb69d57dd
23 changed files with 522 additions and 485 deletions

View File

@@ -5,6 +5,7 @@
#include "MType.h"
#include "Engine/Core/Log.h"
#include "Engine/Core/Types/DataContainer.h"
#include "Engine/Core/Types/Version.h"
#include "Engine/Core/Math/BoundingBox.h"
#include "Engine/Core/Math/BoundingSphere.h"
#include "Engine/Core/Math/Rectangle.h"
@@ -1279,4 +1280,18 @@ void* MUtils::VariantToManagedArgPtr(Variant& value, const MType& type, bool& fa
return nullptr;
}
MonoObject* MUtils::ToManaged(const Version& value)
{
auto obj = mono_object_new(mono_domain_get(), Scripting::FindClassNative("System.Version"));
Platform::MemoryCopy((byte*)obj + sizeof(MonoObject), &value, sizeof(Version));
return obj;
}
Version MUtils::ToNative(MonoObject* value)
{
if (value)
return *(Version*)((byte*)value + sizeof(MonoObject));
return Version();
}
#endif

View File

@@ -14,6 +14,8 @@
#include <ThirdParty/mono-2.0/mono/metadata/object.h>
#include <ThirdParty/mono-2.0/mono/metadata/appdomain.h>
struct Version;
namespace MUtils
{
extern FLAXENGINE_API StringView ToString(MonoString* str);
@@ -500,6 +502,9 @@ namespace MUtils
}
extern void* VariantToManagedArgPtr(Variant& value, const MType& type, bool& failed);
extern MonoObject* ToManaged(const Version& value);
extern Version ToNative(MonoObject* value);
};
#endif