1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//! `ClassLayout` table loader implementation.
//!
//! This module provides the [`crate::metadata::tables::classlayout::loader::ClassLayoutLoader`]
//! implementation for loading `ClassLayout` metadata from the ECMA-335 `ClassLayout` table (0x0F).
//! The loader processes explicit memory layout information for value types and classes that
//! require specific field positioning and packing, integrating this data with existing type definitions.
//!
//! # Architecture
//!
//! The loader follows the standard metadata loading pattern, implementing the
//! [`crate::metadata::loader::MetadataLoader`] trait to process table data and integrate
//! memory layout information with previously loaded [`crate::metadata::tables::typedef::TypeDefRaw`] entries.
//!
//! # Key Components
//!
//! - [`crate::metadata::tables::classlayout::loader::ClassLayoutLoader`] - Main loader implementation
//! - [`crate::metadata::tables::classlayout::ClassLayoutRaw`] - Raw table row structure
//! - [`crate::metadata::loader::LoaderContext`] - Context for loading operations
//!
//! # Table Structure
//!
//! The `ClassLayout` table contains zero or more rows that specify explicit layout for types:
//! - **`PackingSize`**: Byte boundary alignment for fields (1, 2, 4, 8, 16, etc.)
//! - **`ClassSize`**: Total size of the type in bytes (0 for auto-sizing)
//! - **Parent**: Reference to the `TypeDef` table entry for the type
//!
//! # Memory Layout Control
//!
//! `ClassLayout` entries provide precise control over memory representation for types that need:
//! - **Native Interoperability**: Types that must match C/C++ struct layouts
//! - **Performance Optimization**: Explicit packing to reduce memory overhead
//! - **Binary Compatibility**: Fixed layouts for serialization or persistence
//! - **Hardware Interfaces**: Types that map to hardware registers or protocols
//!
//! # Dependencies
//!
//! This loader depends on the `TypeDef` table being loaded first, as it needs to update
//! existing type definition entries with memory layout information.
//!
//! # Integration
//!
//! This module integrates with:
//! - [`crate::metadata::loader`] - Core metadata loading infrastructure
//! - [`crate::metadata::tables::typedef`] - Type definition table entries
//! - [`crate::metadata::tables::classlayout`] - `ClassLayout` table types
//!
//! # References
//!
//! - [ECMA-335 II.22.8](https://ecma-international.org/wp-content/uploads/ECMA-335_6th_edition_june_2012.pdf) - `ClassLayout` table specification
use crate::;
/// Loader for the `ClassLayout` metadata table
///
/// Implements [`crate::metadata::loader::MetadataLoader`] to process the `ClassLayout` table (0x0F)
/// which contains explicit memory layout information for types that require specific field
/// positioning and packing. This table is used primarily for value types and classes that
/// interoperate with native code or have specific memory layout requirements.
///
/// # Layout Types
///
/// `ClassLayout` entries support various memory layout strategies:
/// - **Sequential**: Fields laid out in declaration order with automatic padding
/// - **Explicit**: Each field has an explicitly specified offset
/// - **Auto**: Runtime determines optimal layout (no `ClassLayout` entry needed)
///
/// # Thread Safety
///
/// This type is [`Send`] and [`Sync`] as it contains no mutable state and all operations
/// are read-only during the metadata loading phase. The loader uses parallel iteration
/// for performance when processing multiple `ClassLayout` entries.
pub ;