MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / RegisterType

Method RegisterType

Source/Engine/Engine/NativeInterop.cs:1662–1697  ·  view source on GitHub ↗
(Type type, bool registerNativeType = false)

Source from the content-addressed store, hash-verified

1660 }
1661
1662 internal static (TypeHolder typeHolder, ManagedHandle handle) RegisterType(Type type, bool registerNativeType = false)
1663 {
1664 // TODO: should this strip by-ref?
1665
1666 (TypeHolder typeHolder, ManagedHandle handle) tuple;
1667 tuple.typeHolder = new TypeHolder(type);
1668 tuple.handle = ManagedHandle.Alloc(tuple.typeHolder);
1669#if FLAX_EDITOR
1670 bool isCollectible = type.IsCollectible;
1671 if (!isCollectible && type.IsGenericType && !type.Assembly.IsCollectible)
1672 {
1673 // The owning assembly of a generic type with type arguments referencing
1674 // collectible assemblies must be one of the collectible assemblies.
1675 foreach (var genericType in type.GetGenericArguments())
1676 {
1677 if (genericType.Assembly.IsCollectible)
1678 {
1679 isCollectible = true;
1680 break;
1681 }
1682 }
1683 }
1684
1685 if (isCollectible)
1686 managedTypesCollectible.Add(type, tuple);
1687 else
1688#endif
1689 {
1690 managedTypes.Add(type, tuple);
1691 }
1692
1693 if (registerNativeType)
1694 RegisterNativeClassFromType(tuple.typeHolder, tuple.handle);
1695
1696 return tuple;
1697 }
1698
1699 internal static class TypeHelpers<T>
1700 {

Callers

nothing calls this directly

Calls 3

GetGenericArgumentsMethod · 0.80
AllocMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected