UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMObjectInline.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 "UObject/UnrealType.h" // For FProperty
14#include "VerseVM/VVMObject.h"
16#include "VerseVM/VVMRef.h"
18
19// NOTE: (yiliang.siew) Silence these warnings for now in the cases below.
20#if defined(__GNUC__) || defined(__clang__)
21#pragma GCC diagnostic push
22#pragma GCC diagnostic ignored "-Wswitch-enum"
23#endif
24
25namespace Verse
26{
27template <typename TBinaryFunction>
28bool VObject::AllFields(FAllocationContext Context, TBinaryFunction F)
29{
31 for (auto I = EmergentType->Shape->CreateFieldsIterator(); I; ++I)
32 {
33 if (!::Invoke(F, I->Key->AsStringView(), LoadField(Context, *EmergentType, &I->Value)))
34 {
35 return false;
36 }
37 }
38 return true;
39}
40
41inline FOpResult VObject::LoadField(FAllocationContext Context, const VUniqueString& Name, FLoadFieldCacheCase* OutCacheCase)
42{
44 return LoadField(Context, *EmergentType, EmergentType->Shape->GetField(Name), OutCacheCase);
45}
46
47inline FOpResult VObject::SetField(FAllocationContext Context, const VShape& Shape, const VUniqueString& Name, void* Data, VValue Value)
48{
49 const VShape::VEntry* Field = Shape.GetField(Name);
50 V_DIE_IF(Field == nullptr);
51 return SetField(Context, *Field, Data, Value);
52}
53
54inline FOpResult VObject::SetField(FAllocationContext Context, const VShape::VEntry& Field, void* Data, VValue Value)
55{
56 switch (Field.Type)
57 {
58 case EFieldType::Offset:
59 BitCast<VRestValue*>(Data)[Field.Index].Set(Context, Value);
60 return {FOpResult::Return};
61 case EFieldType::FProperty:
62 return VNativeRef::Set<false>(Context, nullptr, Data, Field.UProperty, Value);
63 case EFieldType::FPropertyVar:
64 return VNativeRef::Set<false>(Context, nullptr, Data, Field.UProperty, Value.StaticCast<VRef>().Get(Context));
65 case EFieldType::FVerseProperty:
66 Field.UProperty->ContainerPtrToValuePtr<VRestValue>(Data)->Set(Context, Value);
67 return {FOpResult::Return};
68 case EFieldType::Constant:
69 default:
70 VERSE_UNREACHABLE(); // This shouldn't happen since such field's data should be on the shape, not the object.
71 break;
72 }
73}
74
75inline FOpResult VObject::SetField(FAllocationContext Context, const VUniqueString& Name, VValue Value)
76{
78 return SetField(Context, *EmergentType->Shape, Name, GetData(*EmergentType->CppClassInfo), Value);
79}
80
81} // namespace Verse
82#if defined(__GNUC__) || defined(__clang__)
83#pragma GCC diagnostic pop
84#endif
85#endif // WITH_VERSE_VM
AUTORTFM_INFER UE_FORCEINLINE_HINT constexpr auto Invoke(FuncType &&Func, ArgTypes &&... Args) -> decltype(((FuncType &&) Func)((ArgTypes &&) Args...))
Definition Invoke.h:44
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
#define VERSE_UNREACHABLE()
Definition VVMUnreachable.h:8
GeometryCollection::Facades::FMuscleActivationData Data
Definition MuscleActivationConstraints.h:15
Definition FieldSystemNoiseAlgo.cpp:6
Definition Archive.h:36