Files
FlaxEngine/Source/Engine/Tests/TestScripting.h
Wojciech Figat a7e428a21c Merge branch 'master' into 1.5
# Conflicts:
#	Content/Shaders/GI/DDGI.flax
#	Content/Shaders/GI/GlobalSurfaceAtlas.flax
#	Content/Shaders/TAA.flax
#	Content/Shaders/VolumetricFog.flax
#	Source/Editor/CustomEditors/Editors/ActorTagEditor.cs
#	Source/Engine/Core/Config/GraphicsSettings.cpp
#	Source/Engine/Engine/PostProcessEffect.cs
#	Source/Engine/Graphics/GPUResourcesCollection.cpp
#	Source/Engine/Graphics/GPUResourcesCollection.h
#	Source/Engine/Graphics/PostProcessBase.h
#	Source/FlaxEngine.Gen.cs
2023-01-10 15:37:55 +01:00

79 lines
2.0 KiB
C++

// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
#pragma once
#include "Engine/Core/ISerializable.h"
#include "Engine/Core/Math/Vector3.h"
#include "Engine/Core/Collections/Array.h"
#include "Engine/Scripting/ScriptingObject.h"
// Test structure.
API_STRUCT(NoDefault) struct TestStruct : public ISerializable
{
API_AUTO_SERIALIZATION();
DECLARE_SCRIPTING_TYPE_MINIMAL(TestStruct);
// Var
API_FIELD() Float3 Vector = Float3::One;
// Ref
API_FIELD() ScriptingObject* Object = nullptr;
friend bool operator==(const TestStruct& lhs, const TestStruct& rhs)
{
return lhs.Vector == rhs.Vector && lhs.Object == rhs.Object;
}
};
// Test structure.
API_STRUCT(NoDefault) struct TestStructPOD
{
DECLARE_SCRIPTING_TYPE_MINIMAL(TestStructPOD);
// Var
API_FIELD() Float3 Vector = Float3::One;
};
template<>
struct TIsPODType<TestStructPOD>
{
enum { Value = true };
};
// Test interface.
API_INTERFACE() class ITestInterface
{
DECLARE_SCRIPTING_TYPE_MINIMAL(ITestInterface);
~ITestInterface() = default;
// Test abstract method
API_FUNCTION() virtual int32 TestInterfaceMethod(const String& str) = 0;
};
// Test class.
API_CLASS() class TestClassNative : public ScriptingObject, public ISerializable, public ITestInterface
{
API_AUTO_SERIALIZATION();
DECLARE_SCRIPTING_TYPE(TestClassNative);
public:
// Test value
API_FIELD() int32 SimpleField = 1;
// Test struct
API_FIELD() TestStruct SimpleStruct;
// Test event
API_EVENT() Delegate<int32, Float3, const String&, String&, const Array<TestStruct>&, Array<TestStruct>&> SimpleEvent;
// Test virtual method
API_FUNCTION() virtual int32 TestMethod(const String& str, API_PARAM(Ref) TestStructPOD& pod, const Array<TestStruct>& struct1, API_PARAM(Ref) Array<TestStruct>& struct2, API_PARAM(Out) Array<ScriptingObject*>& objects)
{
return str.Length();
}
int32 TestInterfaceMethod(const String& str) override
{
return str.Length();
}
};