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
//! Event table implementation for .NET event definitions
//!
//! This module provides complete support for the ECMA-335 Event metadata table (0x14),
//! which contains event definitions for .NET types. Events represent notification mechanisms
//! that allow objects to communicate state changes and important occurrences to interested
//! observers using the observer pattern. The module includes raw table access, resolved data structures,
//! and integration with the broader metadata system.
//!
//! # Architecture
//!
//! The Event table is designed to support .NET's event model, which provides type-safe
//! notification mechanisms for object-oriented programming. Events follow a standard pattern
//! with add/remove accessor methods and optional raise functionality. The table structure
//! includes event attributes, names, and type references that enable full compile-time and
//! runtime verification of event contracts.
//!
//! # Key Components
//!
//! - [`crate::metadata::tables::event::EventRaw`] - Raw table structure with unresolved heap indices
//! - [`crate::metadata::tables::event::Event`] - Owned variant with resolved references and parsed event metadata
//! - [`crate::metadata::tables::event::EventLoader`] - Internal loader for processing Event table data
//! - [`crate::metadata::tables::event::EventMap`] - Thread-safe concurrent map for caching event entries
//! - [`crate::metadata::tables::event::EventList`] - Thread-safe append-only vector for event collections
//! - [`crate::metadata::tables::event::EventRc`] - Reference-counted pointer for shared ownership
//! - [`crate::metadata::tables::event::EventAttributes`] - Constants for event attribute flags
//!
//! # Usage Examples
//!
//! ```rust,no_run
//! use dotscope::metadata::tables::{Event, EventMap};
//! use dotscope::metadata::token::Token;
//!
//! # fn example(events: &EventMap) -> dotscope::Result<()> {
//! // Get a specific event by token
//! let token = Token::new(0x14000001); // Event table token
//! if let Some(event) = events.get(&token) {
//! println!("Event name: {}", event.value().name);
//! println!("Event flags: {:#x}", event.value().flags);
//! println!("Event type: {:?}", event.value().event_type);
//! }
//! # Ok(())
//! # }
//! ```
//!
//! # Event Architecture
//!
//! .NET events provide these key capabilities:
//! - **Type Safety**: Event handler type is verified at compile time through coded indices
//! - **Multicast Support**: Multiple subscribers can be attached to a single event instance
//! - **Standard Pattern**: Consistent add/remove accessor methods with optional custom raise method
//! - **Metadata Integration**: Full reflection and debugging support through event metadata
//! - **Attribute Control**: Special naming and runtime behavior flags for advanced scenarios
//!
//! # Error Handling
//!
//! This module handles error conditions during event processing:
//! - Event name resolution failures when string heap indices are invalid (returns [`crate::Error`])
//! - Event type resolution errors when coded indices cannot be resolved (returns [`crate::Error`])
//! - Accessor method lookup failures when MethodSemantics references are broken (returns [`crate::Error`])
//!
//! # Thread Safety
//!
//! All types in this module are [`Send`] and [`Sync`]. The [`crate::metadata::tables::event::EventMap`] and [`crate::metadata::tables::event::EventList`]
//! use lock-free concurrent data structures for efficient multi-threaded access during metadata analysis.
//!
//! # Integration
//!
//! This module integrates with:
//! - [`crate::metadata::tables`] - Core metadata table infrastructure
//! - [`crate::metadata::token`] - Token-based metadata references
//! - [`crate::metadata::loader`] - Metadata loading system
//! - [`crate::metadata::streams::Strings`] - String heap for event name resolution
//! - Type system tables for event handler type resolution
//!
//! # References
//!
//! - [ECMA-335 II.22.13](https://ecma-international.org/wp-content/uploads/ECMA-335_6th_edition_june_2012.pdf) - Event table specification
use crateToken;
use SkipMap;
use Arc;
pub use *;
pub use *;
pub use *;
pub use *;
/// A map that holds the mapping of [`crate::metadata::token::Token`] to parsed [`Event`]
///
/// Thread-safe concurrent map using skip list data structure for efficient lookups
/// and insertions. Used to cache resolved event definitions by their metadata tokens.
pub type EventMap = ;
/// A vector that holds a list of [`Event`] references
///
/// Thread-safe append-only vector for storing event collections. Uses atomic operations
/// for lock-free concurrent access and is optimized for scenarios with frequent reads.
pub type EventList = ;
/// A reference-counted pointer to an [`Event`]
///
/// Provides shared ownership and automatic memory management for event instances.
/// Multiple references can safely point to the same event data across threads.
pub type EventRc = ;
/// Event flags bit field constants
///
/// Defines event-level attributes that control event behavior and special naming conventions.
/// These flags are stored in the Event table's `EventFlags` field and indicate whether the
/// event has special meaning or requires special handling by the runtime.
///
/// # Reference
/// - [ECMA-335 II.23.1.4](https://ecma-international.org/wp-content/uploads/ECMA-335_6th_edition_june_2012.pdf) - `EventAttributes` enumeration