UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMNativeFunction.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
9#include "VVMFalse.h"
11#include "VVMScope.h"
12#include "VVMType.h"
13#include "VerseVM/VVMNames.h"
14
15namespace Verse
16{
17struct FOpResult;
18struct VPackage;
19struct VTask;
20struct VUniqueString;
21
23
24// A function that is implemented in C++
26{
29
30 static constexpr char DecoratorString[] = "Native";
31
32 // Interface between VerseVM and C++
33 using Args = TArrayView<VValue>;
34 using FThunkFn = FNativeCallResult (*)(FRunningContext, VValue Self, Args Arguments);
35
37
38 // The C++ function to call
40
43
44 static VNativeFunction& New(FAllocationContext Context, uint32 NumPositionalParameters, FThunkFn Thunk, VUniqueString& InName, VValue InSelf)
45 {
46 return *new (Context.AllocateFastCell(sizeof(VNativeFunction))) VNativeFunction(Context, NumPositionalParameters, Thunk, &InName, InSelf);
47 }
48
49 VNativeFunction& Bind(FAllocationContext Context, VValue InSelf)
50 {
51 checkf(!HasSelf(), TEXT("Attempting to bind `Self` to a `VNativeFunction` that already has it set; this is probably a mistake in the code generation."));
52 return VNativeFunction::New(Context, NumPositionalParameters, Thunk, *Name, InSelf);
53 }
54
55 // Lookup a native function and set it's thunk to a C++ function
57
58 COREUOBJECT_API bool HasSelf() const;
59
60 COREUOBJECT_API void AppendToStringImpl(FAllocationContext Context, FUtf8StringBuilderBase& Builder, EValueStringFormat Format, TSet<const void*>& VisitedObjects, uint32 RecursionDepth);
61 static void SerializeLayout(FAllocationContext Context, VNativeFunction*& This, FStructuredArchiveVisitor& Visitor);
62 void SerializeImpl(FAllocationContext Context, FStructuredArchiveVisitor& Visitor);
63
64private:
68 , Thunk(InThunk)
69 , Name(Context, InName)
71 {
72 }
73};
74
75} // namespace Verse
76#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
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 ArrayView.h:139
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