MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / is_blueprintable

Function is_blueprintable

crates/codegen/src/unrealcpp.rs:6249–6296  ·  view source on GitHub ↗

Helper function to check if a type is blueprintable as a field (UPROPERTY)

(module: &ModuleDef, ty: &AlgebraicTypeUse)

Source from the content-addressed store, hash-verified

6247
6248// Helper function to check if a type is blueprintable as a field (UPROPERTY)
6249fn is_blueprintable(module: &ModuleDef, ty: &AlgebraicTypeUse) -> bool {
6250 match ty {
6251 AlgebraicTypeUse::Primitive(p) => match p {
6252 // These types are not blueprintable in Unreal Engine
6253 PrimitiveType::I8 | PrimitiveType::I16 | PrimitiveType::U16 | PrimitiveType::U32 | PrimitiveType::U64 => {
6254 false
6255 }
6256 // All other primitive types are blueprintable
6257 _ => true,
6258 },
6259 // Arrays are blueprintable if their element type is a struct/enum/primitive that can be used in Blueprint
6260 // TArray<USTRUCT> is always blueprintable, even if the USTRUCT has non-blueprintable fields
6261 AlgebraicTypeUse::Array(inner) => match inner.as_ref() {
6262 AlgebraicTypeUse::Ref(r) => {
6263 // TArray<CustomType> is blueprintable if CustomType is a UStruct/UEnum
6264 match &module.typespace_for_generate()[*r] {
6265 AlgebraicTypeDef::Product(_) => true, // TArray<USTRUCT> is always blueprintable
6266 AlgebraicTypeDef::Sum(_) => true, // TArray<UENUM> is always blueprintable
6267 AlgebraicTypeDef::PlainEnum(_) => true, // TArray<PlainEnum> is always blueprintable
6268 }
6269 }
6270 // For primitive arrays, check if the primitive is blueprintable
6271 _ => is_blueprintable(module, inner),
6272 },
6273 AlgebraicTypeUse::String => true,
6274 AlgebraicTypeUse::Identity => true,
6275 AlgebraicTypeUse::ConnectionId => true,
6276 AlgebraicTypeUse::Timestamp => true,
6277 AlgebraicTypeUse::TimeDuration => true,
6278 AlgebraicTypeUse::Uuid => true,
6279 AlgebraicTypeUse::ScheduleAt => true, // ScheduleAt is blueprintable as a property (TObjectPtr)
6280 AlgebraicTypeUse::Unit => true,
6281 AlgebraicTypeUse::Ref(r) => {
6282 // For struct/class fields, USTRUCTs and UENUMs are always blueprintable as field types
6283 // The individual fields within the struct may not be accessible, but the struct itself can be used
6284 match &module.typespace_for_generate()[*r] {
6285 AlgebraicTypeDef::Product(_) => true, // USTRUCTs are always blueprintable as field types
6286 AlgebraicTypeDef::Sum(_) => true, // Sum types are blueprintable
6287 AlgebraicTypeDef::PlainEnum(_) => true, // Enums are blueprintable
6288 }
6289 }
6290 AlgebraicTypeUse::Option(inner) => is_blueprintable(module, inner),
6291 AlgebraicTypeUse::Result { ok_ty, err_ty } => {
6292 is_blueprintable(module, ok_ty) && is_blueprintable(module, err_ty)
6293 }
6294 AlgebraicTypeUse::Never => false,
6295 }
6296}
6297
6298// Helper function to check if a type can be used as a delegate parameter
6299// For delegates, structs are blueprintable even if they contain non-blueprintable fields

Callers 6

generate_reducer_fileMethod · 0.85
autogen_cpp_structFunction · 0.85
autogen_cpp_sumFunction · 0.85

Calls 2

as_refMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…