Reflection.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include <stdint.h>
  3. #include "il2cpp-config.h"
  4. struct Il2CppString;
  5. struct Il2CppArray;
  6. struct Il2CppReflectionAssembly;
  7. struct Il2CppReflectionAssemblyName;
  8. struct Il2CppReflectionField;
  9. struct Il2CppReflectionMethod;
  10. struct Il2CppReflectionModule;
  11. struct Il2CppReflectionProperty;
  12. struct Il2CppReflectionEvent;
  13. struct Il2CppReflectionType;
  14. struct Il2CppReflectionParameter;
  15. struct Il2CppClass;
  16. struct FieldInfo;
  17. struct MethodInfo;
  18. struct PropertyInfo;
  19. struct EventInfo;
  20. struct Il2CppClass;
  21. struct CustomAttributesCache;
  22. struct CustomAttributeTypeCache;
  23. struct Il2CppAssembly;
  24. struct Il2CppAssemblyName;
  25. struct Il2CppImage;
  26. struct Il2CppType;
  27. struct Il2CppObject;
  28. struct MonoGenericParameterInfo;
  29. struct Il2CppGenericParameter;
  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 Il2CppReflectionModule* GetModuleObject(const Il2CppImage *image);
  46. static Il2CppReflectionType* GetTypeObject(const Il2CppType *type);
  47. static Il2CppArray* GetParamObjects(const MethodInfo *method, Il2CppClass *refclass);
  48. static CustomAttributesCache* GetCustomAttrsInfo(Il2CppObject *obj);
  49. static const MonoGenericParameterInfo* GetMonoGenericParameterInfo(const Il2CppGenericParameter *param);
  50. static void SetMonoGenericParameterInfo(const Il2CppGenericParameter *param, const MonoGenericParameterInfo *monoParam);
  51. static const Il2CppMonoAssemblyName* GetMonoAssemblyName(const Il2CppAssembly *assembly);
  52. static void SetMonoAssemblyName(const Il2CppAssembly *assembly, const Il2CppMonoAssemblyName *aname);
  53. static bool HasAttribute(Il2CppObject *obj, Il2CppClass *attribute);
  54. static bool HasAttribute(FieldInfo *field, Il2CppClass *attribute);
  55. static bool HasAttribute(const MethodInfo *method, Il2CppClass *attribute);
  56. static bool HasAttribute(Il2CppClass *klass, Il2CppClass *attribute);
  57. static bool IsType(Il2CppObject *obj);
  58. static bool IsField(Il2CppObject *obj);
  59. static bool IsAnyMethod(Il2CppObject *obj);
  60. static bool IsProperty(Il2CppObject *obj);
  61. static bool IsEvent(Il2CppObject *obj);
  62. // internal
  63. public:
  64. static void Initialize();
  65. static bool CustomAttrsHasAttr(CustomAttributeTypeCache *ainfo, Il2CppClass *attr_klass);
  66. static Il2CppClass* TypeGetHandle(Il2CppReflectionType* ref);
  67. static Il2CppObject* GetDBNullObject();
  68. private:
  69. static CustomAttributeTypeCache* GetCustomAttrsTypeInfo(Il2CppObject *obj);
  70. static CustomAttributeTypeCache* GetCustomAttributeTypeCacheFor(Il2CppReflectionParameter *parameter);
  71. static CustomAttributesCache* GetCustomAttributesCacheFor(Il2CppClass *klass);
  72. static CustomAttributesCache* GetCustomAttributesCacheFor(const MethodInfo *method);
  73. static CustomAttributesCache* GetCustomAttributesCacheFor(const PropertyInfo *property);
  74. static CustomAttributesCache* GetCustomAttributesCacheFor(FieldInfo *field);
  75. static CustomAttributesCache* GetCustomAttributesCacheFor(const EventInfo *event);
  76. static CustomAttributesCache* GetCustomAttributesCacheFor(Il2CppReflectionParameter *param);
  77. static CustomAttributesCache* GetCustomAttributesCacheFor(const Il2CppAssembly *assembly);
  78. };
  79. } /* namespace vm */
  80. } /* namespace il2cpp */