UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMNativeStructInline.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#if WITH_VERSE_VM || defined(__INTELLISENSE__)
5
6#include "VerseVM/VVMClass.h"
9#include "VerseVM/VVMObject.h"
10
11namespace Verse
12{
13
14template <class CppStructType>
15inline CppStructType& VNativeStruct::GetStruct()
16{
18
19 return *BitCast<CppStructType*>(GetStruct());
20}
21
22inline void* VNativeStruct::GetStruct()
23{
24 return VObject::GetData(*GetEmergentType()->CppClassInfo);
25}
26
27inline UScriptStruct* VNativeStruct::GetUScriptStruct(VEmergentType& EmergentType)
28{
29 return EmergentType.Type->StaticCast<VClass>().GetUETypeChecked<UScriptStruct>();
30}
31
32template <class CppStructType>
33inline VNativeStruct& VNativeStruct::New(FAllocationContext Context, VEmergentType& InEmergentType, CppStructType&& InStruct)
34{
36 bool bHasDestructor = (ScriptStruct->StructFlags & STRUCT_NoDestructor) == 0;
38}
39
40inline VNativeStruct& VNativeStruct::NewUninitialized(FAllocationContext Context, VEmergentType& InEmergentType)
41{
43 bool bHasDestructor = (ScriptStruct->StructFlags & STRUCT_NoDestructor) == 0;
45}
46
47inline std::byte* VNativeStruct::AllocateCell(FAllocationContext Context, size_t Size, bool bHasDestructor)
48{
49 const size_t ByteSize = DataOffset(StaticCppClassInfo) + Size;
50 return bHasDestructor ? Context.Allocate(FHeap::DestructorSpace, ByteSize) : Context.AllocateFastCell(ByteSize);
51}
52
53template <class CppStructType>
54inline VNativeStruct::VNativeStruct(FAllocationContext Context, VEmergentType& InEmergentType, CppStructType&& InStruct)
56{
57 using StructType = typename TDecay<CppStructType>::Type;
58 checkSlow(sizeof(StructType) == GetUScriptStruct(InEmergentType)->GetStructureSize());
59
61 void* Data = GetData(*InEmergentType.CppClassInfo);
62
63 // TODO: AutoRTFM::Close and propagate any errors.
64 new (Data) StructType(Forward<CppStructType>(InStruct));
65}
66
67inline VNativeStruct::VNativeStruct(FAllocationContext Context, VEmergentType& InEmergentType)
69{
71
73
74 // TODO: AutoRTFM::Close and propagate any errors.
75 ScriptStruct->InitializeStruct(GetData(*InEmergentType.CppClassInfo));
76}
77
78inline VNativeStruct::VNativeStruct(FAllocationContext Context)
80{
82}
83
84inline VNativeStruct::~VNativeStruct()
85{
88
89 // TODO: AutoRTFM::Close and propagate any errors.
90 ScriptStruct->DestroyStruct(VObject::GetData(*EmergentType->CppClassInfo));
91}
92
93} // namespace Verse
94#endif // WITH_VERSE_VM
#define checkSlow(expr)
Definition AssertionMacros.h:332
@ STRUCT_NoDestructor
Definition Class.h:1060
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
auto GetData(const TStringConversion< Converter, DefaultConversionSize > &Conversion) -> decltype(Conversion.Get())
Definition StringConv.h:802
uint32 Size
Definition VulkanMemory.cpp:4034
Definition Class.h:1720
EStructFlags StructFlags
Definition Class.h:2224
virtual COREUOBJECT_API void InitializeStruct(void *Dest, int32 ArrayDim=1) const override
Definition Class.cpp:3782
virtual COREUOBJECT_API void DestroyStruct(void *Dest, int32 ArrayDim=1) const override
Definition Class.cpp:3940
UE_FORCEINLINE_HINT int32 GetStructureSize() const
Definition Class.h:775
GeometryCollection::Facades::FMuscleActivationData Data
Definition MuscleActivationConstraints.h:15
FORCEINLINE T * Get(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:426
Definition Archive.h:36
UE::Core::Private::Decay::TDecayNonReference< typenameTRemoveReference< T >::Type >::Type Type
Definition Decay.h:45