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

Method MClass

Source/Engine/Scripting/Runtime/DotNet.cpp:940–1001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

938}
939
940MClass::MClass(MAssembly* parentAssembly, void* handle, const char* name, const char* fullname, const char* namespace_, MTypeAttributes attributes)
941 : _handle(handle)
942 , _name(parentAssembly->AllocString(name))
943 , _namespace(parentAssembly->AllocString(namespace_))
944 , _fullname(parentAssembly->AllocString(fullname))
945 , _assembly(parentAssembly)
946 , _methods(&parentAssembly->Memory)
947 , _fields(&parentAssembly->Memory)
948 , _properties(&parentAssembly->Memory)
949 , _attributes(&parentAssembly->Memory)
950 , _events(&parentAssembly->Memory)
951 , _interfaces(&parentAssembly->Memory)
952 , _hasCachedProperties(false)
953 , _hasCachedFields(false)
954 , _hasCachedMethods(false)
955 , _hasCachedAttributes(false)
956 , _hasCachedEvents(false)
957 , _hasCachedInterfaces(false)
958{
959 ASSERT(handle != nullptr);
960 switch (attributes & MTypeAttributes::VisibilityMask)
961 {
962 case MTypeAttributes::NotPublic:
963 case MTypeAttributes::NestedPrivate:
964 _visibility = MVisibility::Private;
965 break;
966 case MTypeAttributes::Public:
967 case MTypeAttributes::NestedPublic:
968 _visibility = MVisibility::Public;
969 break;
970 case MTypeAttributes::NestedFamily:
971 case MTypeAttributes::NestedAssembly:
972 _visibility = MVisibility::Internal;
973 break;
974 case MTypeAttributes::NestedFamORAssem:
975 _visibility = MVisibility::ProtectedInternal;
976 break;
977 case MTypeAttributes::NestedFamANDAssem:
978 _visibility = MVisibility::PrivateProtected;
979 break;
980 default:
981 CRASH;
982 }
983
984 const MTypeAttributes staticClassFlags = MTypeAttributes::Abstract | MTypeAttributes::Sealed;
985 _isStatic = (attributes & staticClassFlags) == staticClassFlags;
986 _isSealed = !_isStatic && (attributes & MTypeAttributes::Sealed) == MTypeAttributes::Sealed;
987 _isAbstract = !_isStatic && (attributes & MTypeAttributes::Abstract) == MTypeAttributes::Abstract;
988 _isInterface = (attributes & MTypeAttributes::ClassSemanticsMask) == MTypeAttributes::Interface;
989
990 // TODO: pass type info from C# side at once (pack into flags with attributes)
991
992 static void* TypeIsValueTypePtr = GetStaticMethodPointer(TEXT("TypeIsValueType"));
993 _isValueType = CallStaticMethod<bool, void*>(TypeIsValueTypePtr, handle);
994
995 static void* TypeIsEnumPtr = GetStaticMethodPointer(TEXT("TypeIsEnum"));
996 _isEnum = CallStaticMethod<bool, void*>(TypeIsEnumPtr, handle);
997

Callers

nothing calls this directly

Calls 3

GetStaticMethodPointerFunction · 0.85
AllocStringMethod · 0.80
FindLastMethod · 0.45

Tested by

no test coverage detected