1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-06 16:25:59 +02:00

Add documentation reflection for comptime

This commit is contained in:
Rune 2025-06-07 10:07:34 +02:00
parent b062c3d2dd
commit 83ccc1662d
5 changed files with 98 additions and 0 deletions

View file

@ -37,6 +37,9 @@ namespace System.Reflection
public int32 FieldIdx => Compiler.IsComptime ?
mFieldData.mCustomAttributesIdx :
-1;
public StringView Documentation => Compiler.IsComptime ?
Type.[Friend]Comptime_Field_GetDocumentation((.)mTypeInstance.TypeId, FieldIdx) :
null;
public void GetSourceName(String outStr)
{

View file

@ -66,6 +66,9 @@ namespace System.Reflection
public StringView Name => Compiler.IsComptime ?
Type.[Friend]Comptime_Method_GetName(mData.mComptimeMethodInstance) :
mData.mMethodData.[Friend]mName;
public StringView Documentation => Compiler.IsComptime ?
Type.[Friend]Comptime_Method_GetDocumentation(mData.mComptimeMethodInstance) :
null;
public void* Ptr => Compiler.IsComptime ?
null :
mData.mMethodData.[Friend]mFuncPtr;

View file

@ -784,6 +784,7 @@ namespace System
static extern Type Comptime_GetTypeByName(StringView name);
static extern String Comptime_Type_ToString(int32 typeId);
static extern String Comptime_TypeName_ToString(int32 typeId);
static extern String Comptime_TypeDocumentation_ToString(int32 typeId);
static extern String Comptime_Namespace_ToString(int32 typeId);
static extern Type Comptime_GetSpecializedType(Type unspecializedType, Span<Type> typeArgs);
static extern bool Comptime_Type_GetCustomAttribute(int32 typeId, int32 attributeIdx, void* dataPtr);
@ -796,10 +797,12 @@ namespace System
static extern int64 Comptime_GetMethod(int32 typeId, int32 methodIdx);
static extern String Comptime_Method_ToString(int64 methodHandle);
static extern String Comptime_Method_GetName(int64 methodHandle);
static extern String Comptime_Method_GetDocumentation(int64 methodHandle);
static extern ComptimeMethodData Comptime_Method_GetInfo(int64 methodHandle);
static extern ComptimeParamInfo Comptime_Method_GetParamInfo(int64 methodHandle, int32 paramIdx);
static extern Type Comptime_Method_GetGenericArg(int64 methodHandle, int32 genericArgIdx);
static extern String Comptime_Field_GetName(int64 fieldHandle);
static extern String Comptime_Field_GetDocumentation(int32 typeId, int32 fieldIndex);
static extern ComptimeFieldInfo Comptime_Field_GetInfo(int64 fieldHandle);
static extern void* Comptime_Field_GetStatic(int32 typeId, int32 fieldIdx);
@ -876,6 +879,12 @@ namespace System
GetBasicName(strBuffer);
}
public virtual void GetDocumentation(String strBuffer)
{
if (Compiler.IsComptime)
strBuffer.Append(Comptime_TypeDocumentation_ToString((.)mTypeId));
}
// Putting this in causes sTypes to be required when Object.ToString is reified
/*public override void ToString(String strBuffer)
{