FieldLayout.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include <stdint.h>
  3. #include <vector>
  4. typedef bool (FieldInfoFilter)(FieldInfo*);
  5. namespace il2cpp
  6. {
  7. namespace metadata
  8. {
  9. struct SizeAndAlignment
  10. {
  11. size_t size;
  12. uint8_t alignment;
  13. };
  14. class FieldLayout
  15. {
  16. public:
  17. struct FieldLayoutData
  18. {
  19. std::vector<size_t> FieldOffsets;
  20. size_t classSize;
  21. size_t actualClassSize;
  22. uint8_t minimumAlignment;
  23. };
  24. static void LayoutInstanceFields(const Il2CppClass* klass, size_t parentSize, size_t actualParentSize, size_t parentAlignment, uint8_t packing, FieldLayoutData& data);
  25. static void LayoutStaticFields(const Il2CppClass* klass, FieldLayoutData& data);
  26. static void LayoutThreadStaticFields(const Il2CppClass* klass, FieldLayoutData& data);
  27. static SizeAndAlignment GetTypeSizeAndAlignment(const Il2CppType* type);
  28. private:
  29. static void LayoutFields(const Il2CppClass* klass, FieldInfoFilter filter, size_t parentSize, size_t actualParentSize, size_t parentAlignment, uint8_t packing, bool isExplicitLayout, FieldLayoutData& data);
  30. };
  31. } /* namespace metadata */
  32. } /* namespace il2cpp */