mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-18 08:06:04 +02:00
Comptime GetCustomAttribute for type/field/method
This commit is contained in:
parent
434a7406de
commit
4c5c89bab5
8 changed files with 110 additions and 13 deletions
|
@ -229,6 +229,13 @@ namespace System.Reflection
|
|||
|
||||
public Result<T> GetCustomAttribute<T>() where T : Attribute
|
||||
{
|
||||
if (Compiler.IsComptime)
|
||||
{
|
||||
T val = ?;
|
||||
if (Type.[Friend]Comptime_Field_GetCustomAttribute((int32)mTypeInstance.TypeId, mFieldData.mCustomAttributesIdx, (.)typeof(T).TypeId, &val))
|
||||
return val;
|
||||
return .Err;
|
||||
}
|
||||
return mTypeInstance.[Friend]GetCustomAttribute<T>(mFieldData.mCustomAttributesIdx);
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,12 @@ namespace System.Reflection
|
|||
public Result<T> GetCustomAttribute<T>() where T : Attribute
|
||||
{
|
||||
if (Compiler.IsComptime)
|
||||
{
|
||||
T val = ?;
|
||||
if (Type.[Friend]Comptime_Method_GetCustomAttribute(mData.mComptimeMethodInstance, (.)typeof(T).TypeId, &val))
|
||||
return val;
|
||||
return .Err;
|
||||
}
|
||||
return mTypeInstance.[Friend]GetCustomAttribute<T>(mData.mMethodData.mCustomAttributesIdx);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue