UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMFunction.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 "VVMClass.h"
8#include "VVMFalse.h"
10#include "VVMScope.h"
11#include "VVMVerse.h"
12
13namespace Verse
14{
15enum class EValueStringFormat;
16struct VProcedure;
17struct VUniqueString;
18
19struct VFunction : VHeapValue
20{
23
25
27
32
35
37 {
38 return InvokeWithSelf(Context, Self.Get(), Argument, NamedArg);
39 }
41 {
42 return InvokeWithSelf(Context, Self.Get(), MoveTemp(Arguments), NamedArgs, NamedArgVals);
43 }
46 COREUOBJECT_API static FOpResult Spawn(FRunningContext Context, VValue Callee, Args&& Arguments, TArray<TWriteBarrier<VUniqueString>>* NamedArgs = nullptr, Args* NamedArgVals = nullptr);
47
48 static VFunction& New(FAllocationContext Context, VProcedure& Procedure, VValue Self, VScope* ParentScope = nullptr)
49 {
50 return *new (Context.AllocateFastCell(sizeof(VFunction))) VFunction(Context, &Procedure, Self, ParentScope);
51 }
52
55 static VFunction& NewUnbound(FAllocationContext Context, VProcedure& Procedure, VScope& InScope)
56 {
57 return *new (Context.AllocateFastCell(sizeof(VFunction))) VFunction(Context, &Procedure, VValue(), &InScope);
58 }
59
60 VFunction& Bind(FAllocationContext Context, VValue InSelf)
61 {
62 checkf(!HasSelf(), TEXT("Attempting to bind `Self` to a `VFunction` that already has it set; this is probably a mistake in the code generation."));
63 checkf(ParentScope, TEXT("The function should already have had its scope set; this is probably a mistake in the code generation."));
64 return *new (Context.AllocateFastCell(sizeof(VFunction))) VFunction(Context, Procedure.Get(), InSelf, ParentScope.Get());
65 }
66
67 VProcedure& GetProcedure() { return *Procedure.Get(); }
68
70 COREUOBJECT_API bool HasSelf() const;
71
72 COREUOBJECT_API void AppendToStringImpl(FAllocationContext Context, FUtf8StringBuilderBase& Builder, EValueStringFormat Format, TSet<const void*>& VisitedObjects, uint32 RecursionDepth);
73
74 static void SerializeLayout(FAllocationContext Context, VFunction*& This, FStructuredArchiveVisitor& Visitor);
75 void SerializeImpl(FAllocationContext Context, FStructuredArchiveVisitor& Visitor);
76
77private:
78 VFunction(FAllocationContext Context, VProcedure* InFunction, VValue InSelf, VScope* InParentScope)
83 {
84 }
85};
86} // namespace Verse
87#endif // WITH_VERSE_VM
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
return Self
Definition CocoaThread.cpp:337
#define TEXT(x)
Definition Platform.h:1272
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
T * New(FMemStackBase &Mem, int32 Count=1, int32 Align=DEFAULT_ALIGNMENT)
Definition MemStack.h:259
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
#define V_FORCEINLINE
Definition VVMVerse.h:30
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Array.h:670
Definition StringBuilder.h:79
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
EValueStringFormat
Definition VVMValuePrinting.h:17