UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ScriptMacros.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 ScriptMacros.h: Kismet VM execution engine.
5=============================================================================*/
6
7#pragma once
8
9// IWYU pragma: begin_keep
10#include "UObject/Script.h"
12#include "UObject/StrProperty.h"
13#include "UObject/UnrealType.h"
14#include "UObject/Stack.h"
17// IWYU pragma: end_keep
18
19/*-----------------------------------------------------------------------------
20 Macros.
21-----------------------------------------------------------------------------*/
22
27enum {MAX_VARIABLE_SIZE = 0x0FFF };
28
29#define ZERO_INIT(Type,ParamName) FMemory::Memzero(&ParamName,sizeof(Type));
30
31#define PARAM_PASSED_BY_VAL(ParamName, PropertyType, ParamType) \
32 ParamType ParamName; \
33 Stack.StepCompiledIn<PropertyType>(&ParamName);
34
35#define PARAM_PASSED_BY_VAL_ZEROED(ParamName, PropertyType, ParamType) \
36 ParamType ParamName = (ParamType)0; \
37 Stack.StepCompiledIn<PropertyType>(&ParamName);
38
39#define PARAM_PASSED_BY_VAL_INITED(ParamName, PropertyType, ParamType, ...) \
40 ParamType ParamName{__VA_ARGS__}; \
41 Stack.StepCompiledIn<PropertyType>(&ParamName);
42
43#define PARAM_PASSED_BY_REF(ParamName, PropertyType, ParamType) \
44 ParamType ParamName##Temp; \
45 ParamType& ParamName = Stack.StepCompiledInRef<PropertyType, ParamType>(&ParamName##Temp);
46
47#define PARAM_PASSED_BY_REF_ZEROED(ParamName, PropertyType, ParamType) \
48 ParamType ParamName##Temp = (ParamType)0; \
49 ParamType& ParamName = Stack.StepCompiledInRef<PropertyType, ParamType>(&ParamName##Temp);
50
51#define P_GET_PROPERTY(PropertyType, ParamName) \
52 PropertyType::TCppType ParamName = PropertyType::GetDefaultPropertyValue(); \
53 Stack.StepCompiledIn<PropertyType>(&ParamName);
54
55#define P_GET_PROPERTY_REF(PropertyType, ParamName) \
56 PropertyType::TCppType ParamName##Temp = PropertyType::GetDefaultPropertyValue(); \
57 PropertyType::TCppType& ParamName = Stack.StepCompiledInRef<PropertyType, PropertyType::TCppType>(&ParamName##Temp);
58
59
60
61#define P_GET_UBOOL(ParamName) uint32 ParamName##32 = 0; bool ParamName=false; Stack.StepCompiledIn<FBoolProperty>(&ParamName##32); ParamName = !!ParamName##32; // translate the bitfield into a bool type for non-intel platforms
62#define P_GET_UBOOL8(ParamName) uint32 ParamName##32 = 0; uint8 ParamName=0; Stack.StepCompiledIn<FBoolProperty>(&ParamName##32); ParamName = ParamName##32 ? 1 : 0; // translate the bitfield into a bool type for non-intel platforms
63#define P_GET_UBOOL16(ParamName) uint32 ParamName##32 = 0; uint16 ParamName=0; Stack.StepCompiledIn<FBoolProperty>(&ParamName##32); ParamName = ParamName##32 ? 1 : 0; // translate the bitfield into a bool type for non-intel platforms
64#define P_GET_UBOOL32(ParamName) uint32 ParamName=0; Stack.StepCompiledIn<FBoolProperty>(&ParamName); ParamName = ParamName ? 1 : 0; // translate the bitfield into a bool type for non-intel platforms
65#define P_GET_UBOOL64(ParamName) uint64 ParamName=0; Stack.StepCompiledIn<FBoolProperty>(&ParamName); ParamName = ParamName ? 1 : 0; // translate the bitfield into a bool type for non-intel platforms
66#define P_GET_UBOOL_REF(ParamName) PARAM_PASSED_BY_REF_ZEROED(ParamName, FBoolProperty, bool)
67
68#define P_GET_STRUCT(StructType,ParamName) PARAM_PASSED_BY_VAL(ParamName, FStructProperty, PREPROCESSOR_COMMA_SEPARATED(StructType))
69#define P_GET_STRUCT_REF(StructType,ParamName) PARAM_PASSED_BY_REF(ParamName, FStructProperty, PREPROCESSOR_COMMA_SEPARATED(StructType))
70
71#define P_GET_OBJECT(ObjectType,ParamName) PARAM_PASSED_BY_VAL_ZEROED(ParamName, FObjectPropertyBase, ObjectType*)
72#define P_GET_OBJECT_REF(ObjectType,ParamName) PARAM_PASSED_BY_REF_ZEROED(ParamName, FObjectPropertyBase, ObjectType*)
73
74#define P_GET_OBJECT_NO_PTR(ObjectType,ParamName) PARAM_PASSED_BY_VAL_ZEROED(ParamName, FObjectPropertyBase, ObjectType)
75#define P_GET_OBJECT_REF_NO_PTR(ObjectType,ParamName) PARAM_PASSED_BY_REF_ZEROED(ParamName, FObjectPropertyBase, ObjectType)
76
77#define P_GET_TARRAY(ElementType,ParamName) PARAM_PASSED_BY_VAL(ParamName, FArrayProperty, TArray<ElementType>)
78#define P_GET_TARRAY_REF(ElementType,ParamName) PARAM_PASSED_BY_REF(ParamName, FArrayProperty, TArray<ElementType>)
79
80#define P_GET_TMAP(KeyType,ValueType,ParamName) PARAM_PASSED_BY_VAL(ParamName, FMapProperty, PREPROCESSOR_COMMA_SEPARATED(TMap<KeyType, ValueType>))
81#define P_GET_TMAP_REF(KeyType,ValueType,ParamName) PARAM_PASSED_BY_REF(ParamName, FMapProperty, PREPROCESSOR_COMMA_SEPARATED(TMap<KeyType, ValueType>))
82
83#define P_GET_TSET(ElementType,ParamName) PARAM_PASSED_BY_VAL(ParamName, FSetProperty, TSet<ElementType>)
84#define P_GET_TSET_REF(ElementType,ParamName) PARAM_PASSED_BY_REF(ParamName, FSetProperty, TSet<ElementType>)
85
86#define P_GET_TINTERFACE(ObjectType,ParamName) PARAM_PASSED_BY_VAL(ParamName, FInterfaceProperty, TScriptInterface<ObjectType>)
87#define P_GET_TINTERFACE_REF(ObjectType,ParamName) PARAM_PASSED_BY_REF(ParamName, FInterfaceProperty, TScriptInterface<ObjectType>)
88
89#define P_GET_WEAKOBJECT(ObjectType,ParamName) PARAM_PASSED_BY_VAL(ParamName, FWeakObjectProperty, ObjectType)
90#define P_GET_WEAKOBJECT_REF(ObjectType,ParamName) PARAM_PASSED_BY_REF(ParamName, FWeakObjectProperty, ObjectType)
91
92#define P_GET_WEAKOBJECT_NO_PTR(ObjectType,ParamName) PARAM_PASSED_BY_VAL(ParamName, FWeakObjectProperty, ObjectType)
93#define P_GET_WEAKOBJECT_REF_NO_PTR(ObjectType,ParamName) PARAM_PASSED_BY_REF(ParamName, FWeakObjectProperty, ObjectType)
94
95#define P_GET_SOFTOBJECT(ObjectType,ParamName) PARAM_PASSED_BY_VAL(ParamName, FSoftObjectProperty, ObjectType)
96#define P_GET_SOFTOBJECT_REF(ObjectType,ParamName) PARAM_PASSED_BY_REF(ParamName, FSoftObjectProperty, ObjectType)
97
98#define P_GET_SOFTCLASS(ObjectType,ParamName) PARAM_PASSED_BY_VAL(ParamName, FSoftClassProperty, ObjectType)
99#define P_GET_SOFTCLASS_REF(ObjectType,ParamName) PARAM_PASSED_BY_REF(ParamName, FSoftClassProperty, ObjectType)
100
101#define P_GET_TFIELDPATH(FieldType,ParamName) PARAM_PASSED_BY_VAL(ParamName, FFieldPathProperty, FieldType)
102#define P_GET_TFIELDPATH_REF(FieldType,ParamName) PARAM_PASSED_BY_REF(ParamName, FFieldPathProperty, FieldType)
103
104#define P_GET_ARRAY(ElementType,ParamName) ElementType ParamName[(MAX_VARIABLE_SIZE/sizeof(ElementType))+1]; Stack.StepCompiledIn<FProperty>(ParamName);
105#define P_GET_ARRAY_REF(ElementType,ParamName) ElementType ParamName##Temp[(MAX_VARIABLE_SIZE/sizeof(ElementType))+1]; ElementType* ParamName = Stack.StepCompiledInRef<FProperty, ElementType*>(ParamName##Temp);
106
107#define P_GET_ENUM(EnumType,ParamName) EnumType ParamName = (EnumType)0; Stack.StepCompiledIn<FEnumProperty>(&ParamName);
108#define P_GET_ENUM_REF(EnumType,ParamName) PARAM_PASSED_BY_REF_ZEROED(ParamName, FEnumProperty, EnumType)
109
110// The following macros are not supported by blueprints but exist for Verse generated functions
111
112#define P_GET_UTF8CHAR(PropertyType, ParamName) UTF8CHAR ParamName = (UTF8CHAR)0; Stack.StepCompiledIn<FByteProperty>(&ParamName);
113#define P_GET_UTF8CHAR_REF(PropertyType, ParamName) UTF8CHAR ParamName##Temp = (UTF8CHAR)0; UTF8CHAR& ParamName = Stack.StepCompiledInRef<FByteProperty, UTF8CHAR>(&ParamName##Temp);
114
115#define P_GET_OBJECTPTR(ElementType,ParamName) PARAM_PASSED_BY_VAL(ParamName, FObjectPropertyBase, TObjectPtr<ElementType>)
116#define P_GET_OBJECTPTR_REF(ElementType,ParamName) PARAM_PASSED_BY_REF(ParamName, FObjectPropertyBase, TObjectPtr<ElementType>)
117
118#define P_GET_VERSETYPE(ParamName) PARAM_PASSED_BY_VAL_INITED(ParamName, FObjectPropertyBase, verse::type, Verse::EDefaultConstructNativeType::UnsafeDoNotUse)
119#define P_GET_VERSETYPE_REF(ParamName) PARAM_PASSED_BY_REF(ParamName, FObjectPropertyBase, verse::type)
120
121#define P_GET_VERSESUBTYPE(ElementType, ParamName) PARAM_PASSED_BY_VAL_INITED(ParamName, FObjectPropertyBase, verse::subtype<ElementType>, Verse::EDefaultConstructNativeType::UnsafeDoNotUse)
122#define P_GET_VERSESUBTYPE_REF(ElementType, ParamName) PARAM_PASSED_BY_REF(ParamName, FObjectPropertyBase, verse::subtype<ElementType>)
123
124#define P_GET_VERSECASTABLETYPE(ParamName) PARAM_PASSED_BY_VAL_INITED(ParamName, FObjectPropertyBase, verse::castable_type, Verse::EDefaultConstructNativeType::UnsafeDoNotUse)
125#define P_GET_VERSECASTABLETYPE_REF(ParamName) PARAM_PASSED_BY_REF(ParamName, FObjectPropertyBase, verse::castable_type)
126
127#define P_GET_VERSECASTABLESUBTYPE(ElementType, ParamName) PARAM_PASSED_BY_VAL_INITED(ParamName, FObjectPropertyBase, verse::castable_subtype<ElementType>, Verse::EDefaultConstructNativeType::UnsafeDoNotUse)
128#define P_GET_VERSECASTABLESUBTYPE_REF(ElementType, ParamName) PARAM_PASSED_BY_REF(ParamName, FObjectPropertyBase, verse::castable_subtype<ElementType>)
129
130#define P_GET_VERSECONCRETETYPE(ParamName) PARAM_PASSED_BY_VAL_INITED(ParamName, FObjectPropertyBase, verse::castable_type, Verse::EDefaultConstructNativeType::UnsafeDoNotUse)
131#define P_GET_VERSECONCRETETYPE_REF(ParamName) PARAM_PASSED_BY_REF(ParamName, FObjectPropertyBase, verse::castable_type)
132
133#define P_GET_VERSECONCRETESUBTYPE(ElementType, ParamName) PARAM_PASSED_BY_VAL_INITED(ParamName, FObjectPropertyBase, verse::concrete_subtype<ElementType>, Verse::EDefaultConstructNativeType::UnsafeDoNotUse)
134#define P_GET_VERSECONCRETESUBTYPE_REF(ElementType, ParamName) PARAM_PASSED_BY_REF(ParamName, FObjectPropertyBase, verse::concrete_subtype<ElementType>)
135
136#define P_GET_INTERFACEINSTANCE(ElementType, ParamName) PARAM_PASSED_BY_VAL_INITED(ParamName, FObjectPropertyBase, TInterfaceInstance<ElementType>, EDefaultConstructNonNullPtr::UnsafeDoNotUse)
137#define P_GET_INTERFACEINSTANCE_REF(ElementType, ParamName) PARAM_PASSED_BY_REF(ParamName, FObjectPropertyBase, TInterfaceInstance<ElementType>)
138
139#define P_GET_TOPTIONAL(ElementType,ParamName) PARAM_PASSED_BY_VAL(ParamName, FOptionalProperty, TOptional<ElementType>)
140#define P_GET_TOPTIONAL_REF(ElementType,ParamName) PARAM_PASSED_BY_REF(ParamName, FOptionalProperty, TOptional<ElementType>)
141#define P_FINISH Stack.Code += !!Stack.Code; /* increment the code ptr unless it is null */
142
143#define P_THIS_OBJECT (Context)
144#define P_THIS_CAST(ClassType) ((ClassType*)P_THIS_OBJECT)
145#define P_THIS P_THIS_CAST(ThisClass)
146
147#define P_NATIVE_BEGIN { SCOPED_SCRIPT_NATIVE_TIMER(ScopedNativeCallTimer);
148#define P_NATIVE_END }
149
150#ifndef UE_SCRIPT_ARGS_GC_BARRIER
151#define UE_SCRIPT_ARGS_GC_BARRIER 1
152#endif
153
154#if UE_SCRIPT_ARGS_GC_BARRIER
155#define P_ARG_GC_BARRIER(X) MutableView(ObjectPtrWrap(X))
156#else
157#define P_ARG_GC_BARRIER(X) X
158#endif
@ MAX_VARIABLE_SIZE
Definition ScriptMacros.h:27