VisualScriptValue
32 bytes on a 64-bit build: the tags, one 16-byte slot shared by every scalar, the quaternion and the object handle, and one pointer to the copy-on-write block holding strings, containers and struct instances. It used to carry all of those side by side (~240 bytes, then ~150), and pin outputs, variables and call arguments are copied by value on every evaluation.
- Module
- VisualScripting
- Header
#include "VisualScripting/VisualScriptValue.h"- Namespace
Mowo
Only the slot member type names is meaningful. Writing one member and reading another reinterprets bytes, so a value must never carry two scalar facts at once (pack them into one member, as the Timeline state packs into v4) and cross-type readers go through the typed accessors below.
Properties
| Type | Name | Description |
|---|---|---|
FMValueType | type | The one-byte tags sit together so the struct pays a single padding run for all of them. Default FMValueType::Void. |
VisualScriptContainer | container | Default VisualScriptContainer::None. |
FMValueType | keyType | Map only Default FMValueType::Void. |
VisualScriptObjRef | objRef | Object CONSTANT: how it resolves Default VisualScriptObjRef::None. |
bool | objWeak | Object pins hold a WEAK handle — never a hard pointer and never a GC root, so a graph can outlive its referent safely. objWeak distinguishes a live object value (resolve through object.weak) from a legacy raw pointer. Default false. |
bool | assetRef | A String CONSTANT that names an asset: the graph serializer writes it as a typed reference so the cook, delete-safety and map check see it, and reading a typed value back sets it again. Runtime values ignore it. Default false. |
FVisualScriptHeapRef | heap |
Public functions
| Returns | Name | Description |
|---|---|---|
const std::string& | Str | Strings, container elements, map keys and struct instances live in the shared block. |
std::string& | MutableStr | |
const std::vector<VisualScriptValue>& | Items | Array elements / Map values / Set elements |
std::vector<VisualScriptValue>& | MutableItems | |
const std::vector<VisualScriptValue>& | Keys | Map keys (parallel to Items) |
std::vector<VisualScriptValue>& | MutableKeys | |
const FVisualScriptStructBox& | Struct | Custom: the struct instance and its ops |
FVisualScriptStructBox& | MutableStruct | |
Vec2 | AsVec2 | The typed view of the shared slot, zero when type is something else. |
Vec3 | AsVec3 | |
Vec4 | AsVec4 | |
Quat | AsQuat | A zero quaternion is not a rotation; it is what an unwritten Quat slot holds, and it has always meant the identity. |
VisualScriptValue | MakeBool | |
VisualScriptValue | MakeInt | |
VisualScriptValue | MakeUInt | |
VisualScriptValue | MakeFloat | |
VisualScriptValue | MakeVec2 | |
VisualScriptValue | MakeVec3 | |
VisualScriptValue | MakeVec4 | |
VisualScriptValue | MakeQuat | |
VisualScriptValue | MakeObject | |
VisualScriptValue | MakeString | |
VisualScriptValue | MakeStruct | A default-constructed struct of the named type, or an empty Custom value (no storage — a call taking it is refused) when the type is not registered. |
const char* | StructName | |
VisualScriptValue | FromObject | A live object pin from an MObject — captures a weak handle (the only GC-safe way to hold an object in a graph value). |
VisualScriptValue | MakeObjectRef | A serialized object reference (Self / find-by-name / find-by-tag), resolved against the live world when the graph runs. |
MObject* | ResolveObject | The live MObject behind an object pin, or nullptr when empty / collected / not an object at all — the handle shares the scalar slot, so another type's bytes must never be read as a pointer. |
bool | HasLiveWeakObject | A weak object handle that still resolves — what a constant object pin dropped in from the world carries. |
bool | IsObjectRef | |
VisualScriptValue | MakeArray | |
VisualScriptValue | MakeMap | |
VisualScriptValue | MakeSet | |
bool | IsArray | |
bool | IsMap | |
bool | IsSet | |
bool | IsContainer | |
size_t | Count | |
bool | Equals | Structural equality — the comparison behind array Contains/Find and map key lookup. |
int | FindKey | Index of key in a map's key list, or -1. |
bool | AsBoolean | |
int64_t | AsInteger | |
double | AsFloating | |
void* | Storage | Pointer to the storage matching type (for the invoke ABI). |
void | PrepareForReturn | Allocate the right field for a given return type so Invoke can write it. |
Function details
Str
const std::string& Str() constStrings, container elements, map keys and struct instances live in the shared block. The const views never allocate (an absent block reads empty); the Mutable ones create the block, or clone it when another value still shares it.
MutableStr
std::string& MutableStr()Items
const std::vector<VisualScriptValue>& Items() constArray elements / Map values / Set elements
MutableItems
std::vector<VisualScriptValue>& MutableItems()Keys
const std::vector<VisualScriptValue>& Keys() constMap keys (parallel to Items)
MutableKeys
std::vector<VisualScriptValue>& MutableKeys()Struct
const FVisualScriptStructBox& Struct() constCustom: the struct instance and its ops
MutableStruct
FVisualScriptStructBox& MutableStruct()AsVec2
Vec2 AsVec2() constThe typed view of the shared slot, zero when type is something else.
AsVec3
Vec3 AsVec3() constAsVec4
Vec4 AsVec4() constAsQuat
Quat AsQuat() constA zero quaternion is not a rotation; it is what an unwritten Quat slot holds, and it has always meant the identity.
MakeBool
static VisualScriptValue MakeBool(bool x)MakeInt
static VisualScriptValue MakeInt(int32_t x)MakeUInt
static VisualScriptValue MakeUInt(uint32_t x)MakeFloat
static VisualScriptValue MakeFloat(float x)MakeVec2
static VisualScriptValue MakeVec2(const Vec2& x)MakeVec3
static VisualScriptValue MakeVec3(const Vec3& x)MakeVec4
static VisualScriptValue MakeVec4(const Vec4& x)MakeQuat
static VisualScriptValue MakeQuat(const Quat& x)MakeObject
static VisualScriptValue MakeObject(void* p)MakeString
static VisualScriptValue MakeString(const std::string& s)MakeStruct
static VisualScriptValue MakeStruct(const FMStructOps* ops)A default-constructed struct of the named type, or an empty Custom value (no storage — a call taking it is refused) when the type is not registered.
StructName
const char* StructName() constFromObject
static VisualScriptValue FromObject(MObject* p)A live object pin from an MObject — captures a weak handle (the only GC-safe way to hold an object in a graph value).
MakeObjectRef
static VisualScriptValue MakeObjectRef(VisualScriptObjRef kind, const std::string& ref)A serialized object reference (Self / find-by-name / find-by-tag), resolved against the live world when the graph runs.
ResolveObject
MObject* ResolveObject() constThe live MObject behind an object pin, or nullptr when empty / collected / not an object at all — the handle shares the scalar slot, so another type's bytes must never be read as a pointer. Weak-checked, so a swept referent reads back as null (never a dangle).
HasLiveWeakObject
bool HasLiveWeakObject() constA weak object handle that still resolves — what a constant object pin dropped in from the world carries.
IsObjectRef
bool IsObjectRef() constMakeArray
static VisualScriptValue MakeArray(FMValueType elemType)MakeMap
static VisualScriptValue MakeMap(FMValueType keyT, FMValueType valueT)MakeSet
static VisualScriptValue MakeSet(FMValueType elemType)IsArray
bool IsArray() constIsMap
bool IsMap() constIsSet
bool IsSet() constIsContainer
bool IsContainer() constCount
size_t Count() constEquals
static bool Equals(const VisualScriptValue& a, const VisualScriptValue& b)Structural equality — the comparison behind array Contains/Find and map key lookup. Numeric types compare by value across int/float.
FindKey
int FindKey(const VisualScriptValue& key) constIndex of key in a map's key list, or -1.
AsBoolean
bool AsBoolean() constAsInteger
int64_t AsInteger() constAsFloating
double AsFloating() constStorage
void* Storage()Pointer to the storage matching type (for the invoke ABI). Returns nullptr for Void / unsupported types and for containers (a container never marshals into a reflected call). A String or Custom value is made unshared first: the thunk may write through the pointer.
PrepareForReturn
void PrepareForReturn(FMValueType retType)Allocate the right field for a given return type so Invoke can write it.