UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMType.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
7#include "VVMCell.h"
8#include "VVMContext.h"
10#include "VVMWriteBarrier.h"
11#include <new>
12
13namespace Verse
14{
15struct VCppClassInfo;
16
17template <typename T>
18struct TGlobalHeapPtr;
19
20// Represents Verse types, which may be independent of object shape, and independent of C++ type.
21struct VType : VHeapValue
22{
24
25protected:
26 COREUOBJECT_API explicit VType(FAllocationContext Context, VEmergentType* Type);
27};
28
29struct VTrivialType : VType
30{
32
34
35 static void Initialize(FAllocationContext Context);
36
37private:
38 VTrivialType(FAllocationContext Context);
39};
40
41#define DECLARE_PRIMITIVE_TYPE(Name) \
42 struct V##Name##Type : VType \
43 { \
44 DECLARE_DERIVED_VCPPCLASSINFO(COREUOBJECT_API, VType); \
45 COREUOBJECT_API static TGlobalTrivialEmergentTypePtr<&StaticCppClassInfo> GlobalTrivialEmergentType; \
46 \
47 COREUOBJECT_API static TGlobalHeapPtr<V##Name##Type> Singleton; \
48 \
49 static constexpr bool SerializeIdentity = false; \
50 static void SerializeLayout(FAllocationContext Context, V##Name##Type*& This, FStructuredArchiveVisitor& Visitor); \
51 void SerializeImpl(FAllocationContext Context, FStructuredArchiveVisitor& Visitor); \
52 \
53 static void Initialize(FAllocationContext Context); \
54 \
55 COREUOBJECT_API TSharedPtr<FJsonValue> ToJSONImpl(FRunningContext Context, EValueJSONFormat Format, TMap<const void*, EVisitState>& VisitedObjects, const VerseVMToJsonCallback& Callback, uint32 RecursionDepth, FJsonObject* Defs); \
56 COREUOBJECT_API VValue FromJSONImpl(FRunningContext Context, const FJsonValue& JsonValue, EValueJSONFormat Format); \
57 \
58 private: \
59 V##Name##Type(FAllocationContext Context); \
60 }
61
62#define DECLARE_STRUCTURAL_TYPE(Name, Fields) \
63 struct V##Name##Type : VType \
64 { \
65 DECLARE_DERIVED_VCPPCLASSINFO(COREUOBJECT_API, VType); \
66 COREUOBJECT_API static TGlobalTrivialEmergentTypePtr<&StaticCppClassInfo> GlobalTrivialEmergentType; \
67 \
68 TWriteBarrier<VValue> Fields(DECLARE_STRUCTURAL_TYPE_FIELD); \
69 \
70 static V##Name##Type& New(FAllocationContext Context, Fields(DECLARE_STRUCTURAL_TYPE_PARAM)) \
71 { \
72 return *new (Context.AllocateFastCell(sizeof(V##Name##Type))) V##Name##Type(Context, Fields(NAME_STRUCTURAL_TYPE_PARAM)); \
73 } \
74 \
75 static constexpr bool SerializeIdentity = false; \
76 static void SerializeLayout(FAllocationContext Context, V##Name##Type*& This, FStructuredArchiveVisitor& Visitor); \
77 void SerializeImpl(FAllocationContext Context, FStructuredArchiveVisitor& Visitor); \
78 \
79 COREUOBJECT_API TSharedPtr<FJsonValue> ToJSONImpl(FRunningContext Context, EValueJSONFormat Format, TMap<const void*, EVisitState>& VisitedObjects, const VerseVMToJsonCallback& Callback, uint32 RecursionDepth, FJsonObject* Defs); \
80 COREUOBJECT_API VValue FromJSONImpl(FRunningContext Context, const FJsonValue& JsonValue, EValueJSONFormat Format); \
81 \
82 protected: \
83 V##Name##Type(FAllocationContext& Context, Fields(DECLARE_STRUCTURAL_TYPE_PARAM), VEmergentType* EmergentType) \
84 : VType(Context, EmergentType) \
85 , Fields(INIT_STRUCTURAL_TYPE_FIELD) \
86 { \
87 } \
88 \
89 private: \
90 V##Name##Type(FAllocationContext& Context, Fields(DECLARE_STRUCTURAL_TYPE_PARAM)) \
91 : V##Name##Type(Context, Fields(NAME_STRUCTURAL_TYPE_PARAM), &GlobalTrivialEmergentType.Get(Context)) \
92 { \
93 } \
94 };
95#define DECLARE_STRUCTURAL_TYPE_FIELD(Name) Name
96#define DECLARE_STRUCTURAL_TYPE_PARAM(Name) VValue In##Name
97#define NAME_STRUCTURAL_TYPE_PARAM(Name) In##Name
98#define INIT_STRUCTURAL_TYPE_FIELD(Name) Name(Context, In##Name)
99
102DECLARE_PRIMITIVE_TYPE(Comparable);
108
109#define TYPE_FIELDS(Field) Field(PositiveType)
111#undef TYPE_FIELDS
112
113#define TYPE_FIELDS(Field) Field(ElementType)
115#undef TYPE_FIELDS
116
117#define TYPE_FIELDS(Field) Field(ElementType)
119#undef TYPE_FIELDS
120
121#define TYPE_FIELDS(Field) Field(KeyType), Field(ValueType)
123#undef TYPE_FIELDS
124
125#define TYPE_FIELDS(Field) Field(ValueType)
127#undef TYPE_FIELDS
128
129DECLARE_PRIMITIVE_TYPE(Reference);
130
131#define TYPE_FIELDS(Field) Field(ValueType)
133#undef TYPE_FIELDS
134
135#define TYPE_FIELDS(Field) Field(SuperType)
137#undef TYPE_FIELDS
138
139#define TYPE_FIELDS(Field) Field(SuperType)
141#undef TYPE_FIELDS
142
145
146#undef DECLARE_PRIMITIVE_TYPE
147#undef DECLARE_STRUCTURAL_TYPE
148#undef DECLARE_STRUCTURAL_TYPE_FIELD
149#undef DECLARE_STRUCTURAL_TYPE_PARAM
150#undef NAME_STRUCTURAL_TYPE_PARAM
151#undef INIT_STRUCTURAL_TYPE_FIELD
152
153struct VMapType : VWeakMapType
154{
157
158 static VMapType& New(FAllocationContext Context, VValue KeyType, VValue ValueType)
159 {
160 return *new (Context.AllocateFastCell(sizeof(VMapType))) VMapType(Context, KeyType, ValueType);
161 }
162
163 static constexpr bool SerializeIdentity = false;
164 static void SerializeLayout(FAllocationContext Context, VMapType*& This, FStructuredArchiveVisitor& Visitor);
165 void SerializeImpl(FAllocationContext Context, FStructuredArchiveVisitor& Visitor);
166
169
170private:
171 VMapType(FAllocationContext& Context, VValue KeyType, VValue ValueType)
173 {
174 }
175};
176
177} // namespace Verse
178#endif // WITH_VERSE_VM
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
T * New(FMemStackBase &Mem, int32 Count=1, int32 Align=DEFAULT_ALIGNMENT)
Definition MemStack.h:259
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition JsonObject.h:23
Definition JsonValue.h:22
Definition UnrealString.h.inl:34
Definition SharedPointer.h:692
FORCEINLINE T * Get(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:426
bool SerializeImpl(const UScriptStruct *InSourceEventType, const void *InSourceEventData, FLiveLinkSerializedFrameData &OutSerializedData)
Definition LiveLinkCompression.cpp:126
Definition Archive.h:36