Add test case of nested types in scripting

#2582 #2591
This commit is contained in:
Wojtek Figat
2024-05-15 13:09:51 +02:00
parent 17d1d87268
commit 35ddfc2455
2 changed files with 63 additions and 0 deletions

View File

@@ -7,6 +7,16 @@
#include "Engine/Scripting/ManagedCLR/MUtils.h"
#include <ThirdParty/catch2/catch.hpp>
TestNesting::TestNesting(const SpawnParams& params)
: SerializableScriptingObject(params)
{
}
TestNesting2::TestNesting2(const SpawnParams& params)
: SerializableScriptingObject(params)
{
}
TestClassNative::TestClassNative(const SpawnParams& params)
: ScriptingObject(params)
{

View File

@@ -6,6 +6,59 @@
#include "Engine/Core/Math/Vector3.h"
#include "Engine/Core/Collections/Array.h"
#include "Engine/Scripting/ScriptingObject.h"
#include "Engine/Scripting/SerializableScriptingObject.h"
// Test compilation with nested types.
API_CLASS() class TestNesting : public SerializableScriptingObject
{
DECLARE_SCRIPTING_TYPE(TestNesting);
API_AUTO_SERIALIZATION();
// Structure
API_STRUCT() struct TestAttribute : public ISerializable
{
DECLARE_SCRIPTING_TYPE_MINIMAL(TestAttribute);
API_AUTO_SERIALIZATION();
// Enumeration
API_ENUM() enum TestEnum
{
E1, E2,
};
// Enum
API_FIELD() TestEnum Enum = E1;
};
// Attributes
API_FIELD() Array<TestAttribute> Attributes;
// Enum
API_FIELD() TestAttribute::TestEnum Enum = TestAttribute::E1;
};
// Test compilation with nested types.
API_CLASS() class TestNesting2 : public SerializableScriptingObject
{
DECLARE_SCRIPTING_TYPE(TestNesting2);
API_AUTO_SERIALIZATION();
// Structure
API_STRUCT() struct TestAttribute
{
DECLARE_SCRIPTING_TYPE_MINIMAL(TestAttribute);
// Enumeration
API_ENUM() enum TestEnum
{
E1, E2,
};
};
// Attributes
API_FIELD() Array<TestNesting::TestAttribute> Attributes;
// Enum
API_FIELD() TestNesting::TestAttribute::TestEnum Enum = TestNesting::TestAttribute::E1;
};
// Test structure.
API_STRUCT(NoDefault) struct TestStruct : public ISerializable