Reflection.h 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 Il2CppGenericParameter;
  31. struct Il2CppMonoAssemblyName;
  32. namespace il2cpp
  33. {
  34. namespace vm
  35. {
  36. class LIBIL2CPP_CODEGEN_API Reflection
  37. {
  38. // exported
  39. public:
  40. static Il2CppReflectionAssembly* GetAssemblyObject(const Il2CppAssembly *assembly);
  41. static Il2CppReflectionAssemblyName* GetAssemblyNameObject(const Il2CppAssemblyName *assemblyName);
  42. static Il2CppReflectionField* GetFieldObject(Il2CppClass *klass, FieldInfo *field);
  43. static Il2CppReflectionProperty* GetPropertyObject(Il2CppClass *klass, const PropertyInfo *property);
  44. static Il2CppReflectionEvent* GetEventObject(Il2CppClass *klass, const EventInfo *event);
  45. static Il2CppReflectionMethod* GetMethodObject(const MethodInfo *method, Il2CppClass *refclass);
  46. static const MethodInfo* GetMethod(const Il2CppReflectionMethod* method);
  47. static Il2CppReflectionModule* GetModuleObject(const Il2CppImage *image);
  48. static Il2CppReflectionType* GetTypeObject(const Il2CppType *type);
  49. static Il2CppArray* GetParamObjects(const MethodInfo *method, Il2CppClass *refclass);
  50. static CustomAttributesCache* GetCustomAttrsInfo(Il2CppObject *obj);
  51. static const MonoGenericParameterInfo* GetMonoGenericParameterInfo(const Il2CppGenericParameter *param);
  52. static void SetMonoGenericParameterInfo(const Il2CppGenericParameter *param, const MonoGenericParameterInfo *monoParam);
  53. static const Il2CppMonoAssemblyName* GetMonoAssemblyName(const Il2CppAssembly *assembly);
  54. static void SetMonoAssemblyName(const Il2CppAssembly *assembly, const Il2CppMonoAssemblyName *aname);
  55. static bool HasAttribute(Il2CppObject *obj, Il2CppClass *attribute);
  56. static bool HasAttribute(FieldInfo *field, Il2CppClass *attribute);
  57. static bool HasAttribute(const MethodInfo *method, Il2CppClass *attribute);
  58. static bool HasAttribute(Il2CppClass *klass, Il2CppClass *attribute);
  59. static bool IsType(Il2CppObject *obj);
  60. static bool IsField(Il2CppObject *obj);
  61. static bool IsAnyMethod(Il2CppObject *obj);
  62. static bool IsProperty(Il2CppObject *obj);
  63. static bool IsEvent(Il2CppObject *obj);
  64. // internal
  65. public:
  66. static void Initialize();
  67. static Il2CppClass* TypeGetHandle(Il2CppReflectionType* ref);
  68. static Il2CppObject* GetDBNullObject();
  69. static Il2CppObject* GetCustomAttribute(CustomAttributeIndex index, Il2CppClass* attribute);
  70. static Il2CppArray* ConstructCustomAttributes(CustomAttributeIndex index);
  71. static CustomAttributesCache* GetCustomAttributesCacheFor(Il2CppClass *klass);
  72. static CustomAttributesCache* GetCustomAttributesCacheFor(const MethodInfo *method);
  73. private:
  74. static bool HasAttribute(Il2CppReflectionParameter *parameter, Il2CppClass* attribute);
  75. static CustomAttributesCache* GetCustomAttributesCacheFor(const PropertyInfo *property);
  76. static CustomAttributesCache* GetCustomAttributesCacheFor(FieldInfo *field);
  77. static CustomAttributesCache* GetCustomAttributesCacheFor(const EventInfo *event);
  78. static CustomAttributesCache* GetCustomAttributesCacheFor(Il2CppReflectionParameter *param);
  79. static CustomAttributesCache* GetCustomAttributesCacheFor(const Il2CppAssembly *assembly);
  80. };
  81. } /* namespace vm */
  82. } /* namespace il2cpp */