Avoid pre-allocating custom attributes for managed types

This commit is contained in:
2022-12-11 13:54:12 +02:00
parent 84f8e3a4b4
commit b9f11298e8
4 changed files with 57 additions and 4 deletions

View File

@@ -587,6 +587,30 @@ const char* CoreCLR::GetClassFullname(void* klass)
return ((CoreCLRClass*)klass)->GetFullname().Get();
}
bool CoreCLR::HasCustomAttribute(void* klass, void* attribClass)
{
return CoreCLR::GetCustomAttribute(klass, attribClass) != nullptr;
}
bool CoreCLR::HasCustomAttribute(void* klass)
{
return CoreCLR::GetCustomAttribute(klass, nullptr) != nullptr;
}
void* CoreCLR::GetCustomAttribute(void* klass, void* attribClass)
{
return CoreCLR::CallStaticMethodInternal<void*, void*, void*>(TEXT("GetCustomAttribute"), ((CoreCLRClass*)klass)->GetTypeHandle(), ((CoreCLRClass*)attribClass)->GetTypeHandle());
}
Array<void*> CoreCLR::GetCustomAttributes(void* klass)
{
Array<CoreCLRCustomAttribute*> attrib = ((CoreCLRClass*)klass)->GetCustomAttributes();
Array<void*> attributes;
attributes.Resize(attrib.Count(), false);
for (int i = 0; i < attrib.Count(); i++)
attributes.Add(attrib[i]->GetHandle());
return attributes;
}
/*
* loader.h
*/