Reflection.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #pragma once
  2. #include <stdint.h>
  3. #include "il2cpp-config.h"
  4. #include "il2cpp-metadata.h"
  5. struct Il2CppString;
  6. struct Il2CppArray;
  7. struct Il2CppReflectionAssembly;
  8. struct Il2CppReflectionAssemblyName;
  9. struct Il2CppReflectionField;
  10. struct Il2CppReflectionMethod;
  11. struct Il2CppReflectionModule;
  12. struct Il2CppReflectionProperty;
  13. struct Il2CppReflectionEvent;
  14. struct Il2CppReflectionType;
  15. struct Il2CppReflectionParameter;
  16. struct Il2CppClass;
  17. struct FieldInfo;
  18. struct MethodInfo;
  19. struct PropertyInfo;
  20. struct EventInfo;
  21. struct Il2CppClass;
  22. struct CustomAttributesCache;
  23. struct CustomAttributeTypeCache;
  24. struct Il2CppAssembly;
  25. struct Il2CppAssemblyName;
  26. struct Il2CppImage;
  27. struct Il2CppType;
  28. struct Il2CppObject;
  29. struct MonoGenericParameterInfo;
  30. struct Il2CppMonoAssemblyName;
  31. namespace il2cpp
  32. {
  33. namespace vm
  34. {
  35. class LIBIL2CPP_CODEGEN_API Reflection
  36. {
  37. // exported
  38. public:
  39. static Il2CppReflectionAssembly* GetAssemblyObject(const Il2CppAssembly *assembly);
  40. static Il2CppReflectionAssemblyName* GetAssemblyNameObject(const Il2CppAssemblyName *assemblyName);
  41. static Il2CppReflectionField* GetFieldObject(Il2CppClass *klass, FieldInfo *field);
  42. static Il2CppReflectionProperty* GetPropertyObject(Il2CppClass *klass, const PropertyInfo *property);
  43. static Il2CppReflectionEvent* GetEventObject(Il2CppClass *klass, const EventInfo *event);
  44. static Il2CppReflectionMethod* GetMethodObject(const MethodInfo *method, Il2CppClass *refclass);
  45. static const MethodInfo* GetMethod(const Il2CppReflectionMethod* method);
  46. static Il2CppReflectionModule* GetModuleObject(const Il2CppImage *image);
  47. static Il2CppReflectionType* GetTypeObject(const Il2CppType *type);
  48. static Il2CppArray* GetParamObjects(const MethodInfo *method, Il2CppClass *refclass);
  49. static CustomAttributesCache* GetCustomAttrsInfo(Il2CppObject *obj);
  50. static const MonoGenericParameterInfo* GetMonoGenericParameterInfo(Il2CppMetadataGenericParameterHandle param);
  51. static void SetMonoGenericParameterInfo(Il2CppMetadataGenericParameterHandle param, const MonoGenericParameterInfo *monoParam);
  52. static const Il2CppMonoAssemblyName* GetMonoAssemblyName(const Il2CppAssembly *assembly);
  53. static void SetMonoAssemblyName(const Il2CppAssembly *assembly, const Il2CppMonoAssemblyName *aname);
  54. static bool HasAttribute(Il2CppObject *obj, Il2CppClass *attribute);
  55. static bool HasAttribute(FieldInfo *field, Il2CppClass *attribute);
  56. static bool HasAttribute(const MethodInfo *method, Il2CppClass *attribute);
  57. static bool HasAttribute(Il2CppClass *klass, Il2CppClass *attribute);
  58. static bool IsType(Il2CppObject *obj);
  59. static bool IsField(Il2CppObject *obj);
  60. static bool IsAnyMethod(Il2CppObject *obj);
  61. static bool IsProperty(Il2CppObject *obj);
  62. static bool IsEvent(Il2CppObject *obj);
  63. static void ClearStatics();
  64. // internal
  65. public:
  66. static void Initialize();
  67. static Il2CppClass* TypeGetHandle(Il2CppReflectionType* ref);
  68. static Il2CppObject* GetDBNullObject();
  69. static Il2CppClass* GetConstructorInfo();
  70. static Il2CppObject* GetCustomAttribute(Il2CppMetadataCustomAttributeHandle token, Il2CppClass* attribute);
  71. static Il2CppArray* ConstructCustomAttributes(Il2CppMetadataCustomAttributeHandle token);
  72. static CustomAttributesCache* GetCustomAttributesCacheFor(Il2CppClass *klass);
  73. static CustomAttributesCache* GetCustomAttributesCacheFor(const MethodInfo *method);
  74. private:
  75. static bool HasAttribute(Il2CppReflectionParameter *parameter, Il2CppClass* attribute);
  76. static CustomAttributesCache* GetCustomAttributesCacheFor(const PropertyInfo *property);
  77. static CustomAttributesCache* GetCustomAttributesCacheFor(FieldInfo *field);
  78. static CustomAttributesCache* GetCustomAttributesCacheFor(const EventInfo *event);
  79. static CustomAttributesCache* GetCustomAttributesCacheFor(Il2CppReflectionParameter *param);
  80. static CustomAttributesCache* GetCustomAttributesCacheFor(const Il2CppAssembly *assembly);
  81. };
  82. } /* namespace vm */
  83. } /* namespace il2cpp */