1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

AllowDuplicatesAttribute

This commit is contained in:
Brian Fiete 2019-12-25 16:38:17 -08:00
parent 2618b29daa
commit 8808da307f
13 changed files with 39 additions and 2 deletions

View file

@ -49,6 +49,7 @@ namespace Beefy
ShowMaximized = 0x0400'0000,
};
[AllowDuplicates]
public enum HitTestResult
{
NotHandled = -3,

View file

@ -18,14 +18,17 @@ namespace Beefy.widgets
Shift = 0x10,
Control = 0x11,
Alt = 0x12,
#unwarn
Menu = 0x12,
Pause = 0x13,
Capital = 0x14,
Kana = 0x15,
#unwarn
Hangul = 0x15,
Junja = 0x17,
Final = 0x18,
Hanja = 0x19,
#unwarn
Kanji = 0x19,
Escape = 0x1B,
Convert = 0x1C,

View file

@ -1521,6 +1521,7 @@ namespace SDL2
ArrayF32
}
[AllowDuplicates]
public enum SDL_PIXELORDER_ENUM : uint32
{
/* BITMAPORDER */
@ -2967,6 +2968,7 @@ namespace SDL2
void* userdata
);
[AllowDuplicates]
enum EventState : int32
{
Query = -1,
@ -3272,6 +3274,7 @@ namespace SDL2
* and all of the names are in an anonymous enum. Yeah...
* that's not going to cut it for C#. We'll just put them in an
* enum for now? */
[AllowDuplicates]
public enum Keycode : uint32
{
UNKNOWN = 0,

View file

@ -237,6 +237,12 @@ namespace System
}
}
[AttributeUsage(.Enum)]
public struct AllowDuplicatesAttribute : Attribute
{
}
[AttributeUsage(.Class | .Struct)]
public struct UnionAttribute : Attribute
{

View file

@ -251,6 +251,12 @@ namespace System
}
}
[AttributeUsage(.Enum)]
public struct AllowDuplicatesAttribute : Attribute
{
}
[AttributeUsage(.Class | .Struct)]
public struct UnionAttribute : Attribute
{

View file

@ -848,6 +848,7 @@ namespace System.Reflection
EnumDiscriminator = 0x0200
}
[AllowDuplicates]
public enum MethodFlags : int16
{
MethodAccessMask = 0x0007,
@ -869,6 +870,7 @@ namespace System.Reflection
// vtable layout mask - Use this mask to retrieve vtable attributes.
VtableLayoutMask = 0x0100,
ReuseSlot = 0x0000, // The default.
NewSlot = 0x0100, // Method always gets a new slot in the vtable.
// end vtable layout mask

View file

@ -8,11 +8,14 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
[AllowDuplicates]
enum EnumA
{
Abo = 1,
Boop = _*2,
Croop = _*2,
Zoop = 1
}
struct Blurg

View file

@ -762,6 +762,15 @@ bool BfAstNode::IsExpression()
return IsA<BfExpression>();
}
bool BfAstNode::WantsWarning(int warningNumber)
{
auto parserData = GetParserData();
if (parserData == NULL)
return true;
int srcStart = GetSrcStart();
return (!parserData->IsUnwarnedAt(this)) && (parserData->IsWarningEnabledAtSrcIndex(warningNumber, GetSrcStart()));
}
bool BfAstNode::LocationEquals(BfAstNode* otherNode)
{
return (GetSourceData() == otherNode->GetSourceData()) &&

View file

@ -1040,6 +1040,7 @@ public:
void Add(BfAstNode* bfAstNode);
bool IsMissingSemicolon();
bool IsExpression();
bool WantsWarning(int warningNumber);
template <typename T>
bool IsA()

View file

@ -382,6 +382,7 @@ BfCompiler::BfCompiler(BfSystem* bfSystem, bool isResolveOnly)
mImportAttributeTypeDef = NULL;
mCReprAttributeTypeDef = NULL;
mAlignAttributeTypeDef = NULL;
mAllowDuplicatesAttributeTypeDef = NULL;
mNoDiscardAttributeTypeDef = NULL;
mDisableChecksAttributeTypeDef = NULL;
mDisableObjectAccessChecksAttributeTypeDef = NULL;
@ -5856,6 +5857,7 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
mImportAttributeTypeDef = _GetRequiredType("System.ImportAttribute");
mCReprAttributeTypeDef = _GetRequiredType("System.CReprAttribute");
mAlignAttributeTypeDef = _GetRequiredType("System.AlignAttribute");
mAllowDuplicatesAttributeTypeDef = _GetRequiredType("System.AllowDuplicatesAttribute");
mNoDiscardAttributeTypeDef = _GetRequiredType("System.NoDiscardAttribute");
mDisableChecksAttributeTypeDef = _GetRequiredType("System.DisableChecksAttribute");
mDisableObjectAccessChecksAttributeTypeDef = _GetRequiredType("System.DisableObjectAccessChecksAttribute");

View file

@ -380,6 +380,7 @@ public:
BfTypeDef* mImportAttributeTypeDef;
BfTypeDef* mCReprAttributeTypeDef;
BfTypeDef* mAlignAttributeTypeDef;
BfTypeDef* mAllowDuplicatesAttributeTypeDef;
BfTypeDef* mNoDiscardAttributeTypeDef;
BfTypeDef* mDisableChecksAttributeTypeDef;
BfTypeDef* mDisableObjectAccessChecksAttributeTypeDef;

View file

@ -2940,7 +2940,7 @@ BfTypedValue BfExprEvaluator::LookupIdentifier(BfAstNode* refNode, const StringI
}
}
if ((mModule->mCurMethodInstance == NULL) && (mModule->mCurTypeInstance->IsEnum()))
if ((mModule->mCurMethodInstance == NULL) && (mModule->mCurTypeInstance != NULL) && (mModule->mCurTypeInstance->IsEnum()))
{
if (findName == "_")
{

View file

@ -2990,7 +2990,7 @@ bool BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
{
*fieldDefPtr = fieldDef;
}
else
else if ((typeInstance->mCustomAttributes == NULL) || (typeInstance->mCustomAttributes->Get(mCompiler->mAllowDuplicatesAttributeTypeDef) == NULL))
{
auto error = Warn(0, StrFormat("Enum value '%lld' for field '%s' is not unique", foreignConst->mInt64, fieldDef->mName.c_str()), fieldDef->GetRefNode(), true);
if (error != NULL)