mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Better enum autocomplete hygiene
This commit is contained in:
parent
fa1271b662
commit
20c88dfeb0
9 changed files with 109 additions and 37 deletions
|
@ -425,10 +425,18 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[AttributeUsage(.Field | .StaticField | .Method | .Property /*2*/)]
|
[AttributeUsage(.Field | .StaticField | .Method | .Property | .Types)]
|
||||||
public struct NoShowAttribute : Attribute
|
public struct NoShowAttribute : Attribute
|
||||||
{
|
{
|
||||||
|
public this()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public this(bool allowDirect)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[AttributeUsage(.Parameter)]
|
[AttributeUsage(.Parameter)]
|
||||||
|
|
|
@ -5,11 +5,12 @@ namespace System
|
||||||
{
|
{
|
||||||
struct Enum
|
struct Enum
|
||||||
{
|
{
|
||||||
|
[NoShow(true)]
|
||||||
[Comptime(ConstEval=true)]
|
[Comptime(ConstEval=true)]
|
||||||
public static int GetCount()
|
public static int GetCount<T>() where T : Enum
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (var field in Compiler.OrigCalleeType.GetFields())
|
for (var field in typeof(T).GetFields())
|
||||||
{
|
{
|
||||||
if (field.IsEnumCase)
|
if (field.IsEnumCase)
|
||||||
count++;
|
count++;
|
||||||
|
@ -17,13 +18,14 @@ namespace System
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
[Comptime(ConstEval=true)]
|
[Comptime(ConstEval=true)]
|
||||||
public static var GetMinValue()
|
public static var GetMinValue<T>() where T : Enum
|
||||||
{
|
{
|
||||||
Compiler.SetReturnType(Compiler.OrigCalleeType);
|
Compiler.SetReturnType(typeof(T));
|
||||||
|
|
||||||
int? minValue = null;
|
int? minValue = null;
|
||||||
for (var field in Compiler.OrigCalleeType.GetFields())
|
for (var field in typeof(T).GetFields())
|
||||||
{
|
{
|
||||||
if (field.IsEnumCase)
|
if (field.IsEnumCase)
|
||||||
{
|
{
|
||||||
|
@ -36,13 +38,14 @@ namespace System
|
||||||
return minValue.ValueOrDefault;
|
return minValue.ValueOrDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
[Comptime(ConstEval=true)]
|
[Comptime(ConstEval=true)]
|
||||||
public static var GetMaxValue()
|
public static var GetMaxValue<T>() where T : Enum
|
||||||
{
|
{
|
||||||
Compiler.SetReturnType(Compiler.OrigCalleeType);
|
Compiler.SetReturnType(typeof(T));
|
||||||
|
|
||||||
int? maxValue = null;
|
int? maxValue = null;
|
||||||
for (var field in Compiler.OrigCalleeType.GetFields())
|
for (var field in typeof(T).GetFields())
|
||||||
{
|
{
|
||||||
if (field.IsEnumCase)
|
if (field.IsEnumCase)
|
||||||
{
|
{
|
||||||
|
@ -57,6 +60,7 @@ namespace System
|
||||||
return maxValue.ValueOrDefault;
|
return maxValue.ValueOrDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public static void EnumToString(Type type, String strBuffer, int64 iVal)
|
public static void EnumToString(Type type, String strBuffer, int64 iVal)
|
||||||
{
|
{
|
||||||
for (var field in type.GetFields())
|
for (var field in type.GetFields())
|
||||||
|
@ -71,6 +75,7 @@ namespace System
|
||||||
iVal.ToString(strBuffer);
|
iVal.ToString(strBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public static Result<T> Parse<T>(StringView str, bool ignoreCase = false) where T : enum
|
public static Result<T> Parse<T>(StringView str, bool ignoreCase = false) where T : enum
|
||||||
{
|
{
|
||||||
for (var (name, data) in GetEnumerator<T>())
|
for (var (name, data) in GetEnumerator<T>())
|
||||||
|
@ -84,7 +89,8 @@ namespace System
|
||||||
return .Err;
|
return .Err;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsDefined<T>(T value)
|
[NoShow(true)]
|
||||||
|
public static bool IsDefined<T>(T value) where T : Enum
|
||||||
where T : enum
|
where T : enum
|
||||||
{
|
{
|
||||||
for (var data in GetValues<T>())
|
for (var data in GetValues<T>())
|
||||||
|
@ -96,24 +102,28 @@ namespace System
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public static EnumEnumerator<TEnum> GetEnumerator<TEnum>()
|
public static EnumEnumerator<TEnum> GetEnumerator<TEnum>()
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
return .();
|
return .();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public static EnumValuesEnumerator<TEnum> GetValues<TEnum>()
|
public static EnumValuesEnumerator<TEnum> GetValues<TEnum>()
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
return .();
|
return .();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public static EnumNamesEnumerator<TEnum> GetNames<TEnum>()
|
public static EnumNamesEnumerator<TEnum> GetNames<TEnum>()
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
return .();
|
return .();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
private struct EnumFieldsEnumerator<TEnum>
|
private struct EnumFieldsEnumerator<TEnum>
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
|
@ -179,6 +189,7 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public struct EnumEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<(StringView name, TEnum value)>
|
public struct EnumEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<(StringView name, TEnum value)>
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
|
@ -198,6 +209,7 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public struct EnumValuesEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<TEnum>
|
public struct EnumValuesEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<TEnum>
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
|
@ -217,6 +229,7 @@ namespace System
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NoShow(true)]
|
||||||
public struct EnumNamesEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<StringView>
|
public struct EnumNamesEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<StringView>
|
||||||
where TEnum : enum
|
where TEnum : enum
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,7 @@ namespace System
|
||||||
{
|
{
|
||||||
struct ValueType
|
struct ValueType
|
||||||
{
|
{
|
||||||
|
[NoShow(true)]
|
||||||
public static extern bool Equals<T>(T val1, T val2);
|
public static extern bool Equals<T>(T val1, T val2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -712,13 +712,18 @@ const char* BfAutoComplete::GetTypeName(BfType* type)
|
||||||
return "value";
|
return "value";
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfAutoComplete::AddInnerTypes(BfTypeInstance* typeInst, const StringImpl& filter, bool allowProtected, bool allowPrivate)
|
void BfAutoComplete::AddInnerTypes(BfTypeInstance* typeInst, const StringImpl& filter, BfTypeInstance* startType, bool allowProtected, bool allowPrivate)
|
||||||
{
|
{
|
||||||
if (typeInst->IsEnum())
|
if (typeInst->IsEnum())
|
||||||
AddEntry(AutoCompleteEntry("valuetype", "UnderlyingType"), filter);
|
AddEntry(AutoCompleteEntry("valuetype", "UnderlyingType"), filter);
|
||||||
|
|
||||||
|
BfShow checkShow = (typeInst == startType) ? BfShow_Hide : BfShow_HideIndirect;
|
||||||
|
|
||||||
for (auto innerType : typeInst->mTypeDef->mNestedTypes)
|
for (auto innerType : typeInst->mTypeDef->mNestedTypes)
|
||||||
{
|
{
|
||||||
|
if (innerType->mShow >= checkShow)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (innerType->mOuterType->mTypeCode == BfTypeCode_Extension)
|
if (innerType->mOuterType->mTypeCode == BfTypeCode_Extension)
|
||||||
{
|
{
|
||||||
if (typeInst->mDefineState < BfTypeDefineState_Defined)
|
if (typeInst->mDefineState < BfTypeDefineState_Defined)
|
||||||
|
@ -737,7 +742,7 @@ void BfAutoComplete::AddInnerTypes(BfTypeInstance* typeInst, const StringImpl& f
|
||||||
|
|
||||||
allowPrivate = false;
|
allowPrivate = false;
|
||||||
if (typeInst->mBaseType != NULL)
|
if (typeInst->mBaseType != NULL)
|
||||||
AddInnerTypes(typeInst->mBaseType, filter, allowProtected, allowPrivate);
|
AddInnerTypes(typeInst->mBaseType, filter, startType, allowProtected, allowPrivate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfAutoComplete::AddCurrentTypes(BfTypeInstance* typeInst, const StringImpl& filter, bool allowProtected, bool allowPrivate, bool onlyAttribute)
|
void BfAutoComplete::AddCurrentTypes(BfTypeInstance* typeInst, const StringImpl& filter, bool allowProtected, bool allowPrivate, bool onlyAttribute)
|
||||||
|
@ -900,7 +905,7 @@ void BfAutoComplete::AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bo
|
||||||
|
|
||||||
auto activeTypeDef = mModule->GetActiveTypeDef();
|
auto activeTypeDef = mModule->GetActiveTypeDef();
|
||||||
|
|
||||||
if ((addStatic) && (mModule->mCurMethodInstance == NULL) && (typeInst->IsEnum()))
|
if ((addStatic) && (mModule->mCurMethodInstance == NULL) && (typeInst->IsEnum()) && (allowImplicitThis))
|
||||||
{
|
{
|
||||||
AddEntry(AutoCompleteEntry("value", "_"), filter);
|
AddEntry(AutoCompleteEntry("value", "_"), filter);
|
||||||
}
|
}
|
||||||
|
@ -909,6 +914,8 @@ void BfAutoComplete::AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bo
|
||||||
|
|
||||||
mModule->PopulateType(typeInst, BfPopulateType_Data);
|
mModule->PopulateType(typeInst, BfPopulateType_Data);
|
||||||
|
|
||||||
|
BfShow checkShow = (startType == typeInst) ? BfShow_Hide : BfShow_HideIndirect;
|
||||||
|
|
||||||
BfProtectionCheckFlags protectionCheckFlags = BfProtectionCheckFlag_None;
|
BfProtectionCheckFlags protectionCheckFlags = BfProtectionCheckFlag_None;
|
||||||
for (auto& fieldInst : typeInst->mFieldInstances)
|
for (auto& fieldInst : typeInst->mFieldInstances)
|
||||||
{
|
{
|
||||||
|
@ -916,7 +923,7 @@ void BfAutoComplete::AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bo
|
||||||
if (fieldDef == NULL)
|
if (fieldDef == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (fieldDef->mIsNoShow)
|
if (fieldDef->mShow >= checkShow)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((CHECK_STATIC(fieldDef->mIsStatic)) &&
|
if ((CHECK_STATIC(fieldDef->mIsStatic)) &&
|
||||||
|
@ -934,7 +941,7 @@ void BfAutoComplete::AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bo
|
||||||
{
|
{
|
||||||
if (methodDef->mIsOverride)
|
if (methodDef->mIsOverride)
|
||||||
continue;
|
continue;
|
||||||
if (methodDef->mIsNoShow)
|
if (methodDef->mShow >= checkShow)
|
||||||
continue;
|
continue;
|
||||||
if (methodDef->mName.IsEmpty())
|
if (methodDef->mName.IsEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
@ -965,7 +972,7 @@ void BfAutoComplete::AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bo
|
||||||
|
|
||||||
for (auto propDef : typeInst->mTypeDef->mProperties)
|
for (auto propDef : typeInst->mTypeDef->mProperties)
|
||||||
{
|
{
|
||||||
if (propDef->mIsNoShow)
|
if (propDef->mShow >= checkShow)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((!typeInst->IsTypeMemberIncluded(propDef->mDeclaringType, activeTypeDef, mModule)) ||
|
if ((!typeInst->IsTypeMemberIncluded(propDef->mDeclaringType, activeTypeDef, mModule)) ||
|
||||||
|
@ -1016,13 +1023,15 @@ void BfAutoComplete::AddSelfResultTypeMembers(BfTypeInstance* typeInst, BfTypeIn
|
||||||
|
|
||||||
mModule->PopulateType(typeInst, BfPopulateType_Data);
|
mModule->PopulateType(typeInst, BfPopulateType_Data);
|
||||||
|
|
||||||
|
BfShow checkShow = allowPrivate ? BfShow_Hide : BfShow_HideIndirect;
|
||||||
|
|
||||||
for (auto& fieldInst : typeInst->mFieldInstances)
|
for (auto& fieldInst : typeInst->mFieldInstances)
|
||||||
{
|
{
|
||||||
auto fieldDef = fieldInst.GetFieldDef();
|
auto fieldDef = fieldInst.GetFieldDef();
|
||||||
if (fieldDef == NULL)
|
if (fieldDef == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (fieldDef->mIsNoShow)
|
if (fieldDef->mShow > checkShow)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((fieldDef->mIsStatic) && (CheckProtection(fieldDef->mProtection, fieldDef->mDeclaringType, allowProtected, allowPrivate)))
|
if ((fieldDef->mIsStatic) && (CheckProtection(fieldDef->mProtection, fieldDef->mDeclaringType, allowProtected, allowPrivate)))
|
||||||
|
@ -1042,7 +1051,7 @@ void BfAutoComplete::AddSelfResultTypeMembers(BfTypeInstance* typeInst, BfTypeIn
|
||||||
{
|
{
|
||||||
if (methodDef->mIsOverride)
|
if (methodDef->mIsOverride)
|
||||||
continue;
|
continue;
|
||||||
if (methodDef->mIsNoShow)
|
if (methodDef->mShow > checkShow)
|
||||||
continue;
|
continue;
|
||||||
if (methodDef->mName.IsEmpty())
|
if (methodDef->mName.IsEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
@ -1082,7 +1091,7 @@ void BfAutoComplete::AddSelfResultTypeMembers(BfTypeInstance* typeInst, BfTypeIn
|
||||||
|
|
||||||
for (auto propDef : typeInst->mTypeDef->mProperties)
|
for (auto propDef : typeInst->mTypeDef->mProperties)
|
||||||
{
|
{
|
||||||
if (propDef->mIsNoShow)
|
if (propDef->mShow > checkShow)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((!typeInst->IsTypeMemberIncluded(propDef->mDeclaringType, activeTypeDef, mModule)) ||
|
if ((!typeInst->IsTypeMemberIncluded(propDef->mDeclaringType, activeTypeDef, mModule)) ||
|
||||||
|
@ -1216,11 +1225,13 @@ void BfAutoComplete::AddExtensionMethods(BfTypeInstance* targetType, BfTypeInsta
|
||||||
|
|
||||||
mModule->PopulateType(extensionContainer, BfPopulateType_Data);
|
mModule->PopulateType(extensionContainer, BfPopulateType_Data);
|
||||||
|
|
||||||
|
BfShow checkShow = allowPrivate ? BfShow_Hide : BfShow_HideIndirect;
|
||||||
|
|
||||||
for (auto methodDef : extensionContainer->mTypeDef->mMethods)
|
for (auto methodDef : extensionContainer->mTypeDef->mMethods)
|
||||||
{
|
{
|
||||||
if (methodDef->mMethodType != BfMethodType_Extension)
|
if (methodDef->mMethodType != BfMethodType_Extension)
|
||||||
continue;
|
continue;
|
||||||
if (methodDef->mIsNoShow)
|
if (methodDef->mShow >= checkShow)
|
||||||
continue;
|
continue;
|
||||||
if (methodDef->mName.IsEmpty())
|
if (methodDef->mName.IsEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
@ -1596,7 +1607,7 @@ void BfAutoComplete::CheckIdentifier(BfAstNode* identifierNode, bool isInExpress
|
||||||
for (auto typeInst : staticSearch->mStaticTypes)
|
for (auto typeInst : staticSearch->mStaticTypes)
|
||||||
{
|
{
|
||||||
AddTypeMembers(typeInst, true, false, filter, typeInst, true, true, false);
|
AddTypeMembers(typeInst, true, false, filter, typeInst, true, true, false);
|
||||||
AddInnerTypes(typeInst, filter, false, false);
|
AddInnerTypes(typeInst, filter, typeInst, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1977,7 +1988,7 @@ bool BfAutoComplete::CheckMemberReference(BfAstNode* target, BfAstNode* dotToken
|
||||||
bool allowProtected = allowPrivate;
|
bool allowProtected = allowPrivate;
|
||||||
|
|
||||||
if (isStatic)
|
if (isStatic)
|
||||||
AddInnerTypes(typeInst, filter, allowProtected, allowPrivate);
|
AddInnerTypes(typeInst, filter, typeInst, allowProtected, allowPrivate);
|
||||||
|
|
||||||
if (!onlyShowTypes)
|
if (!onlyShowTypes)
|
||||||
{
|
{
|
||||||
|
@ -2116,11 +2127,13 @@ bool BfAutoComplete::CheckExplicitInterface(BfTypeInstance* interfaceType, BfAst
|
||||||
|
|
||||||
auto activeTypeDef = mModule->GetActiveTypeDef();
|
auto activeTypeDef = mModule->GetActiveTypeDef();
|
||||||
|
|
||||||
|
BfShow checkShow = BfShow_Hide;
|
||||||
|
|
||||||
for (auto methodDef : interfaceType->mTypeDef->mMethods)
|
for (auto methodDef : interfaceType->mTypeDef->mMethods)
|
||||||
{
|
{
|
||||||
if (methodDef->mIsOverride)
|
if (methodDef->mIsOverride)
|
||||||
continue;
|
continue;
|
||||||
if (methodDef->mIsNoShow)
|
if (methodDef->mShow >= checkShow)
|
||||||
continue;
|
continue;
|
||||||
if (methodDef->mName.IsEmpty())
|
if (methodDef->mName.IsEmpty())
|
||||||
continue;
|
continue;
|
||||||
|
@ -2617,12 +2630,14 @@ void BfAutoComplete::AddOverrides(const StringImpl& filter)
|
||||||
|
|
||||||
auto activeTypeDef = mModule->GetActiveTypeDef();
|
auto activeTypeDef = mModule->GetActiveTypeDef();
|
||||||
|
|
||||||
|
BfShow checkShow = BfShow_Hide;
|
||||||
|
|
||||||
BfTypeInstance* curType = mModule->mCurTypeInstance;
|
BfTypeInstance* curType = mModule->mCurTypeInstance;
|
||||||
while (curType != NULL)
|
while (curType != NULL)
|
||||||
{
|
{
|
||||||
for (auto methodDef : curType->mTypeDef->mMethods)
|
for (auto methodDef : curType->mTypeDef->mMethods)
|
||||||
{
|
{
|
||||||
if (methodDef->mIsNoShow)
|
if (methodDef->mShow >= checkShow)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool allowInternalOverride = false;
|
bool allowInternalOverride = false;
|
||||||
|
|
|
@ -223,7 +223,7 @@ public:
|
||||||
void AddField(BfTypeInstance* typeInst, BfFieldDef* fieldDef, BfFieldInstance* fieldInstance, const StringImpl& filter);
|
void AddField(BfTypeInstance* typeInst, BfFieldDef* fieldDef, BfFieldInstance* fieldInstance, const StringImpl& filter);
|
||||||
void AddProp(BfTypeInstance* typeInst, BfPropertyDef* propDef, const StringImpl& filter);
|
void AddProp(BfTypeInstance* typeInst, BfPropertyDef* propDef, const StringImpl& filter);
|
||||||
void AddTypeDef(BfTypeDef* typeDef, const StringImpl& filter, bool onlyAttribute = false);
|
void AddTypeDef(BfTypeDef* typeDef, const StringImpl& filter, bool onlyAttribute = false);
|
||||||
void AddInnerTypes(BfTypeInstance* typeInst, const StringImpl& filter, bool allowProtected, bool allowPrivate);
|
void AddInnerTypes(BfTypeInstance* typeInst, const StringImpl& filter, BfTypeInstance* startType, bool allowProtected, bool allowPrivate);
|
||||||
void AddCurrentTypes(BfTypeInstance* typeInst, const StringImpl& filter, bool allowProtected, bool allowPrivate, bool onlyAttribute);
|
void AddCurrentTypes(BfTypeInstance* typeInst, const StringImpl& filter, bool allowProtected, bool allowPrivate, bool onlyAttribute);
|
||||||
void AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bool addNonStatic, const StringImpl& filter, BfTypeInstance* startType, bool allowInterfaces, bool allowImplicitThis, bool checkOuterType);
|
void AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bool addNonStatic, const StringImpl& filter, BfTypeInstance* startType, bool allowInterfaces, bool allowImplicitThis, bool checkOuterType);
|
||||||
void AddSelfResultTypeMembers(BfTypeInstance* typeInst, BfTypeInstance* selfType, const StringImpl& filter, bool allowPrivate);
|
void AddSelfResultTypeMembers(BfTypeInstance* typeInst, BfTypeInstance* selfType, const StringImpl& filter, bool allowPrivate);
|
||||||
|
|
|
@ -851,7 +851,18 @@ void BfDefBuilder::ParseAttributes(BfAttributeDirective* attributes, BfMethodDef
|
||||||
methodDef->mHasComptime = true;
|
methodDef->mHasComptime = true;
|
||||||
}
|
}
|
||||||
else if (typeRefName == "NoShow")
|
else if (typeRefName == "NoShow")
|
||||||
methodDef->mIsNoShow = true;
|
{
|
||||||
|
methodDef->mShow = BfShow_Hide;
|
||||||
|
|
||||||
|
if (!attributes->mArguments.IsEmpty())
|
||||||
|
{
|
||||||
|
if (auto literalExpr = BfNodeDynCast<BfLiteralExpression>(attributes->mArguments[0]))
|
||||||
|
{
|
||||||
|
if (literalExpr->mValue.mBool)
|
||||||
|
methodDef->mShow = BfShow_HideIndirect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (typeRefName == "NoDiscard")
|
else if (typeRefName == "NoDiscard")
|
||||||
methodDef->mIsNoDiscard = true;
|
methodDef->mIsNoDiscard = true;
|
||||||
else if (typeRefName == "NoSplat")
|
else if (typeRefName == "NoSplat")
|
||||||
|
@ -883,7 +894,7 @@ void BfDefBuilder::ParseAttributes(BfAttributeDirective* attributes, BfMethodDef
|
||||||
void BfDefBuilder::ParseAttributes(BfAttributeDirective* attributes, BfTypeDef* typeDef)
|
void BfDefBuilder::ParseAttributes(BfAttributeDirective* attributes, BfTypeDef* typeDef)
|
||||||
{
|
{
|
||||||
while (attributes != NULL)
|
while (attributes != NULL)
|
||||||
{
|
{
|
||||||
if (attributes->mAttributeTypeRef != NULL)
|
if (attributes->mAttributeTypeRef != NULL)
|
||||||
{
|
{
|
||||||
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
auto typeRefName = attributes->mAttributeTypeRef->ToCleanAttributeString();
|
||||||
|
@ -891,7 +902,20 @@ void BfDefBuilder::ParseAttributes(BfAttributeDirective* attributes, BfTypeDef*
|
||||||
if (typeRefName == "AlwaysInclude")
|
if (typeRefName == "AlwaysInclude")
|
||||||
typeDef->mIsAlwaysInclude = true;
|
typeDef->mIsAlwaysInclude = true;
|
||||||
else if (typeRefName == "NoDiscard")
|
else if (typeRefName == "NoDiscard")
|
||||||
typeDef->mIsNoDiscard = true;
|
typeDef->mIsNoDiscard = true;
|
||||||
|
else if (typeRefName == "NoShow")
|
||||||
|
{
|
||||||
|
typeDef->mShow = BfShow_Hide;
|
||||||
|
|
||||||
|
if (!attributes->mArguments.IsEmpty())
|
||||||
|
{
|
||||||
|
if (auto literalExpr = BfNodeDynCast<BfLiteralExpression>(attributes->mArguments[0]))
|
||||||
|
{
|
||||||
|
if (literalExpr->mValue.mBool)
|
||||||
|
typeDef->mShow = BfShow_HideIndirect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
attributes = attributes->mNextAttribute;
|
attributes = attributes->mNextAttribute;
|
||||||
|
|
|
@ -22532,6 +22532,9 @@ void BfModule::GetMethodCustomAttributes(BfMethodInstance* methodInstance)
|
||||||
auto propertyMethodDeclaration = methodDef->GetPropertyMethodDeclaration();
|
auto propertyMethodDeclaration = methodDef->GetPropertyMethodDeclaration();
|
||||||
auto typeInstance = methodInstance->GetOwner();
|
auto typeInstance = methodInstance->GetOwner();
|
||||||
|
|
||||||
|
if (typeInstance->IsInstanceOf(mCompiler->mValueTypeTypeDef))
|
||||||
|
return;
|
||||||
|
|
||||||
BfTypeState typeState(typeInstance);
|
BfTypeState typeState(typeInstance);
|
||||||
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
SetAndRestoreValue<BfTypeState*> prevTypeState(mContext->mCurTypeState, &typeState);
|
||||||
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, typeInstance);
|
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, typeInstance);
|
||||||
|
|
|
@ -2975,7 +2975,7 @@ void BfSystem::InjectNewRevision(BfTypeDef* typeDef)
|
||||||
BF_ASSERT(typeDef->mTypeCode == nextTypeDef->mTypeCode);
|
BF_ASSERT(typeDef->mTypeCode == nextTypeDef->mTypeCode);
|
||||||
|
|
||||||
typeDef->mTypeCode = nextTypeDef->mTypeCode;
|
typeDef->mTypeCode = nextTypeDef->mTypeCode;
|
||||||
|
typeDef->mShow = nextTypeDef->mShow;
|
||||||
typeDef->mIsAlwaysInclude = nextTypeDef->mIsAlwaysInclude;
|
typeDef->mIsAlwaysInclude = nextTypeDef->mIsAlwaysInclude;
|
||||||
typeDef->mIsNoDiscard = nextTypeDef->mIsNoDiscard;
|
typeDef->mIsNoDiscard = nextTypeDef->mIsNoDiscard;
|
||||||
typeDef->mIsPartial = nextTypeDef->mIsPartial;
|
typeDef->mIsPartial = nextTypeDef->mIsPartial;
|
||||||
|
@ -3080,6 +3080,7 @@ void BfSystem::AddToCompositePartial(BfPassInstance* passInstance, BfTypeDef* co
|
||||||
|
|
||||||
typeDef->mSystem = partialTypeDef->mSystem;
|
typeDef->mSystem = partialTypeDef->mSystem;
|
||||||
typeDef->mTypeCode = partialTypeDef->mTypeCode;
|
typeDef->mTypeCode = partialTypeDef->mTypeCode;
|
||||||
|
typeDef->mShow = partialTypeDef->mShow;
|
||||||
typeDef->mIsFunction = partialTypeDef->mIsFunction;
|
typeDef->mIsFunction = partialTypeDef->mIsFunction;
|
||||||
typeDef->mIsDelegate = partialTypeDef->mIsDelegate;
|
typeDef->mIsDelegate = partialTypeDef->mIsDelegate;
|
||||||
typeDef->mNestDepth = partialTypeDef->mNestDepth;
|
typeDef->mNestDepth = partialTypeDef->mNestDepth;
|
||||||
|
@ -3500,9 +3501,7 @@ void BfSystem::CopyTypeDef(BfTypeDef* typeDef, BfTypeDef* fromTypeDef)
|
||||||
typeDef->mProtection = fromTypeDef->mProtection;
|
typeDef->mProtection = fromTypeDef->mProtection;
|
||||||
|
|
||||||
typeDef->mTypeCode = fromTypeDef->mTypeCode;
|
typeDef->mTypeCode = fromTypeDef->mTypeCode;
|
||||||
|
typeDef->mShow = fromTypeDef->mShow;
|
||||||
typeDef->mTypeCode = fromTypeDef->mTypeCode;
|
|
||||||
|
|
||||||
typeDef->mIsAlwaysInclude = fromTypeDef->mIsAlwaysInclude;
|
typeDef->mIsAlwaysInclude = fromTypeDef->mIsAlwaysInclude;
|
||||||
typeDef->mIsNoDiscard = fromTypeDef->mIsNoDiscard;
|
typeDef->mIsNoDiscard = fromTypeDef->mIsNoDiscard;
|
||||||
typeDef->mIsPartial = fromTypeDef->mIsPartial;
|
typeDef->mIsPartial = fromTypeDef->mIsPartial;
|
||||||
|
|
|
@ -536,6 +536,13 @@ enum BfParamKind : uint8
|
||||||
BfParamKind_VarArgs
|
BfParamKind_VarArgs
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum BfShow : uint8
|
||||||
|
{
|
||||||
|
BfShow_Show,
|
||||||
|
BfShow_HideIndirect,
|
||||||
|
BfShow_Hide
|
||||||
|
};
|
||||||
|
|
||||||
class BfParameterDef
|
class BfParameterDef
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -570,7 +577,7 @@ public:
|
||||||
BfProtection mProtection;
|
BfProtection mProtection;
|
||||||
uint8 mNamePrefixCount; // Number of @'s
|
uint8 mNamePrefixCount; // Number of @'s
|
||||||
bool mIsStatic;
|
bool mIsStatic;
|
||||||
bool mIsNoShow;
|
BfShow mShow;
|
||||||
bool mIsReadOnly;
|
bool mIsReadOnly;
|
||||||
bool mHasMultiDefs;
|
bool mHasMultiDefs;
|
||||||
|
|
||||||
|
@ -581,7 +588,7 @@ public:
|
||||||
mProtection = BfProtection_Public;
|
mProtection = BfProtection_Public;
|
||||||
mNamePrefixCount = 0;
|
mNamePrefixCount = 0;
|
||||||
mIsStatic = false;
|
mIsStatic = false;
|
||||||
mIsNoShow = false;
|
mShow = BfShow_Show;
|
||||||
mIsReadOnly = false;
|
mIsReadOnly = false;
|
||||||
mHasMultiDefs = false;
|
mHasMultiDefs = false;
|
||||||
}
|
}
|
||||||
|
@ -1133,7 +1140,8 @@ public:
|
||||||
int mPartialIdx;
|
int mPartialIdx;
|
||||||
int mNestDepth;
|
int mNestDepth;
|
||||||
int mDupDetectedRevision; // Error state
|
int mDupDetectedRevision; // Error state
|
||||||
BfTypeCode mTypeCode;
|
BfTypeCode mTypeCode;
|
||||||
|
BfShow mShow;
|
||||||
bool mIsAlwaysInclude;
|
bool mIsAlwaysInclude;
|
||||||
bool mIsNoDiscard;
|
bool mIsNoDiscard;
|
||||||
bool mIsPartial;
|
bool mIsPartial;
|
||||||
|
@ -1170,7 +1178,8 @@ public:
|
||||||
mNameEx = NULL;
|
mNameEx = NULL;
|
||||||
mSystem = NULL;
|
mSystem = NULL;
|
||||||
mProject = NULL;
|
mProject = NULL;
|
||||||
mTypeCode = BfTypeCode_None;
|
mTypeCode = BfTypeCode_None;
|
||||||
|
mShow = BfShow_Show;
|
||||||
mIsAlwaysInclude = false;
|
mIsAlwaysInclude = false;
|
||||||
mIsNoDiscard = false;
|
mIsNoDiscard = false;
|
||||||
mIsExplicitPartial = false;
|
mIsExplicitPartial = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue