const ESFixedTypeBase* ESolver::CreateEnumType(const string& TypeName, const vector<string>& EnumConstructors) { if(TypeMgr->LookupType(TypeName) != NULL) { throw TypeException("Redeclaration of Type \"" + TypeName + "\""); } // Safety check to ensure that enum constructors are not // repeated set<string> EnumConstructorSet; const uint32 NumEnumConstructors = EnumConstructors.size(); for(uint32 i = 0; i < NumEnumConstructors; ++i) { if(EnumConstructorSet.find(EnumConstructors[i]) != EnumConstructorSet.end()) { throw TypeException((string)"Duplicate Enum constructor \"" + EnumConstructors[i] + "\""); } EnumConstructorSet.insert(EnumConstructors[i]); } auto Retval = TypeMgr->CreateType<ESEnumType>(TypeName, EnumConstructors); TypeMgr->BindType(TypeName, Retval); RegisterType(Retval); // Create values and constant operators for each constructor // Push a bunch of constant operators into the fray. One for each enum constructor for(auto const& EnumConstructor : EnumConstructors) { CreateConstant(TypeName + "::" + EnumConstructor, Retval, EnumConstructor); } return Retval; }
HRESULT InjectedType::RegisterTypeInModule(const ModuleID moduleId) { if (!ShouldRegisterType(moduleId)) { return S_FALSE; } const auto registerTypeResult = RegisterType(moduleId); m_registrationMap[moduleId] = registerTypeResult == S_OK; return registerTypeResult; }
const ESFixedTypeBase* ESolver::CreateBitVectorType(uint32 NumBits) { if(NumBits > ESOLVER_MAX_BV_SIZE) { throw UnimplementedException((string)"Error: ESolver cannot currently handle bit-vectors " + "larger than " + to_string(ESOLVER_MAX_BV_SIZE) + " bits in length"); } string TypeName = ESOLVER_BITVEC_PREFIX + "_" + to_string(NumBits); auto Retval = TypeMgr->LookupType<ESBVType>(TypeName); if (Retval == nullptr) { Retval = TypeMgr->CreateType<ESBVType>(NumBits); TypeMgr->BindType(TypeName, Retval); RegisterType(Retval); } return Retval; }
ezRTTI::ezRTTI(const char* szName, const ezRTTI* pParentType, ezUInt32 uiTypeSize, ezUInt32 uiTypeVersion, ezUInt32 uiVariantType, ezBitflags<ezTypeFlags> flags, ezRTTIAllocator* pAllocator, ezArrayPtr<ezAbstractProperty*> properties, ezArrayPtr<ezAbstractFunctionProperty*> functions, ezArrayPtr<ezPropertyAttribute*> attributes, ezArrayPtr<ezAbstractMessageHandler*> messageHandlers, ezArrayPtr<ezMessageSenderInfo> messageSenders, const ezRTTI* (*fnVerifyParent)()) { UpdateType(pParentType, uiTypeSize, uiTypeVersion, uiVariantType, flags); m_bGatheredDynamicMessageHandlers = false; m_szPluginName = nullptr; m_szTypeName = szName; m_pAllocator = pAllocator; m_Properties = properties; m_Functions = functions; m_Attributes = attributes; m_MessageHandlers = messageHandlers; m_uiMsgIdOffset = 0; m_MessageSenders = messageSenders; m_fnVerifyParent = fnVerifyParent; // This part is not guaranteed to always work here! // pParentType is (apparently) always the correct pointer to the base class BUT it is not guaranteed to have been constructed at this // point in time! Therefore the message handler hierarchy is initialized delayed in DispatchMessage // // However, I don't know where we could do these debug checks where they are guaranteed to be executed. // For now they are executed here and one might also do that in e.g. the game application { #if EZ_ENABLED(EZ_COMPILE_FOR_DEVELOPMENT) VerifyCorrectness(); #endif } if (m_szTypeName) RegisterType(this); }