| 2023 | } |
| 2024 | |
| 2025 | int BfModule::GenerateTypeOptions(BfCustomAttributes* customAttributes, BfTypeInstance* typeInstance, bool checkTypeName) |
| 2026 | { |
| 2027 | if (mContext->mSystem->mTypeOptions.size() == 0) |
| 2028 | { |
| 2029 | return -1; |
| 2030 | } |
| 2031 | |
| 2032 | Array<int> matchedIndices; |
| 2033 | |
| 2034 | if ((!checkTypeName) && (typeInstance->mTypeOptionsIdx != -1)) |
| 2035 | { |
| 2036 | // Methods should 'inherit' the owner's type options before applying type options from custom attributes |
| 2037 | auto typeOptions = mSystem->GetTypeOptions(typeInstance->mTypeOptionsIdx); |
| 2038 | if (typeOptions->mMatchedIndices.size() == 0) |
| 2039 | matchedIndices.push_back(typeInstance->mTypeOptionsIdx); |
| 2040 | else |
| 2041 | matchedIndices = typeOptions->mMatchedIndices; |
| 2042 | } |
| 2043 | |
| 2044 | if (customAttributes != NULL) |
| 2045 | { |
| 2046 | if (!mCompiler->mAttributeTypeOptionMap.IsEmpty()) |
| 2047 | { |
| 2048 | StringT<128> attrName; |
| 2049 | for (auto& customAttrs : customAttributes->mAttributes) |
| 2050 | { |
| 2051 | attrName.Clear(); |
| 2052 | customAttrs.mType->mTypeDef->mFullName.ToString(attrName); |
| 2053 | Array<int>* arrPtr; |
| 2054 | if (mCompiler->mAttributeTypeOptionMap.TryGetValue(attrName, &arrPtr)) |
| 2055 | { |
| 2056 | for (auto optionsIdx : *arrPtr) |
| 2057 | { |
| 2058 | matchedIndices.Add(optionsIdx); |
| 2059 | } |
| 2060 | } |
| 2061 | } |
| 2062 | } |
| 2063 | } |
| 2064 | |
| 2065 | int typeOptionsCount = (int)mContext->mSystem->mTypeOptions.size(); |
| 2066 | if (checkTypeName) |
| 2067 | { |
| 2068 | auto _CheckType = [&](BfType* type) |
| 2069 | { |
| 2070 | StringImpl typeName = TypeToString(type); |
| 2071 | |
| 2072 | for (int optionIdx = 0; optionIdx < (int)mContext->mSystem->mTypeOptions.size(); optionIdx++) |
| 2073 | { |
| 2074 | auto& typeOptions = mContext->mSystem->mTypeOptions[optionIdx]; |
| 2075 | |
| 2076 | bool matched = false; |
| 2077 | for (auto& filter : typeOptions.mTypeFilters) |
| 2078 | { |
| 2079 | int filterIdx = 0; |
| 2080 | int typeNameIdx = 0; |
| 2081 | |
| 2082 | if (filter.StartsWith(':')) |
nothing calls this directly
no test coverage detected