UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMArrayBaseInline.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if WITH_VERSE_VM || defined(__INTELLISENSE__)
6
8#include "VerseVM/VVMArray.h"
10#include "VerseVM/VVMInt.h"
14
15namespace Verse
16{
17
18inline bool VArrayBase::IsInBounds(uint32 Index) const
19{
20 return Index < Num();
21}
22
23inline bool VArrayBase::IsInBounds(const VInt& Index, const uint32 Bounds) const
24{
25 if (Index.IsInt64())
26 {
27 const int64 IndexInt64 = Index.AsInt64();
28 return (IndexInt64 >= 0) && (IndexInt64 < Bounds);
29 }
30 else
31 {
32 // Array maximum size is limited to the maximum size of a unsigned 32-bit integer.
33 // So even if it's a `VHeapInt`, if it fails the `IsInt64` check, it is definitely out-of-bounds.
34 return false;
35 }
36}
37
38inline VValue VArrayBase::GetValue(uint32 Index)
39{
41 switch (GetArrayType())
42 {
43 case EArrayType::VValue:
44 return GetData<VValue>()[Index].Follow();
45 case EArrayType::Int32:
46 return VValue::FromInt32(GetData<int32>()[Index]);
47 case EArrayType::Char8:
48 return VValue::Char(GetData<UTF8CHAR>()[Index]);
49 case EArrayType::Char32:
50 return VValue::Char32(GetData<UTF32CHAR>()[Index]);
51 case EArrayType::None:
52 default:
53 V_DIE("Unhandled EArrayType (%u) encountered!", static_cast<uint32>(GetArrayType()));
54 }
55}
56
57inline const VValue VArrayBase::GetValue(uint32 Index) const
58{
60 switch (GetArrayType())
61 {
62 case EArrayType::VValue:
63 return GetData<VValue>()[Index].Follow();
64 case EArrayType::Int32:
65 return VValue::FromInt32(GetData<int32>()[Index]);
66 case EArrayType::Char8:
67 return VValue::Char(GetData<UTF8CHAR>()[Index]);
68 case EArrayType::Char32:
69 return VValue::Char32(GetData<UTF32CHAR>()[Index]);
70 case EArrayType::None:
71 default:
72 V_DIE("Unhandled EArrayType (%u) encountered!", static_cast<uint32>(GetArrayType()));
73 }
74}
75
76template <bool bTransactional>
77inline void VArrayBase::ConvertDataToVValues(FAllocationContext Context, uint32 NewCapacity)
78{
79 if (GetArrayType() != EArrayType::VValue)
80 {
81 uint32 Num = this->Num();
82 VBuffer NewBuffer = VBuffer(Context, Num, NewCapacity, EArrayType::VValue);
83 for (uint32 Index = 0; Index < Num; ++Index)
84 {
86 }
87
88 // We need to see the store to ArrayType/Num/all the VValues before the GC
89 // sees the buffer itself.
91 }
92}
93
94template <bool bTransactional>
95inline void VArrayBase::SetValueImpl(FAllocationContext Context, uint32 Index, VValue Value)
96{
97 checkSlow(Index < Capacity());
98 EArrayType ArrayType = GetArrayType();
99 if (ArrayType == EArrayType::VValue)
100 {
102 }
103 else if (ArrayType != DetermineArrayType(Value))
104 {
107 }
108 else
109 {
110 auto DoSet = [&] {
111 switch (ArrayType)
112 {
113 case EArrayType::Int32:
114 SetInt32(Index, Value.AsInt32());
115 break;
116 case EArrayType::Char8:
117 SetChar(Index, Value.AsChar());
118 break;
119 case EArrayType::Char32:
120 SetChar32(Index, Value.AsChar32());
121 break;
122 case EArrayType::VValue:
123 case EArrayType::None:
124 default:
125 V_DIE("Unhandled EArrayType (%u) encountered!", static_cast<uint32>(GetArrayType()));
126 }
127 };
128
129 if constexpr (bTransactional)
130 {
131 (void)AutoRTFM::Close(DoSet);
132 }
133 else
134 {
135 DoSet();
136 }
137 }
138}
139
140inline void VArrayBase::SetValue(FAllocationContext Context, uint32 Index, VValue Value)
141{
143}
144
145inline void VArrayBase::SetValueTransactionally(FAllocationContext Context, uint32 Index, VValue Value)
146{
148}
149
150template <typename TArray>
151void VArrayBase::SerializeLayoutImpl(FAllocationContext Context, TArray*& This, FStructuredArchiveVisitor& Visitor)
152{
153 if (Visitor.IsLoading())
154 {
155 This = &TArray::New(Context);
156 }
157}
158
159} // namespace Verse
160#endif // WITH_VERSE_VM
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define checkSlow(expr)
Definition AssertionMacros.h:332
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
@ Num
Definition MetalRHIPrivate.h:234
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Array.h:670
@ Visitor
Definition XmppMultiUserChat.h:94
T::FDataType GetValue(const UBlackboardComponent &Blackboard, const FName &Name, FBlackboard::FKey &InOutCachedKey, const typename T::FDataType &DefaultValue)
Definition ValueOrBBKey.h:51
bool IsInBounds(const FIntVector3 &Point, const FIntVector3 &Min, const FIntVector3 &Max)
Definition SparseVolumeTextureUtility.cpp:202
Definition Archive.h:36
U16 Index
Definition radfft.cpp:71