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
//! # Built-in Derive Macros for Macroforge
//!
//! This module provides the standard derive macros that ship with macroforge-ts.
//! These macros generate common boilerplate methods for TypeScript classes,
//! interfaces, enums, and type aliases.
//!
//! ## Available Macros
//!
//! ### Equality & Hashing
//!
//! | Macro | Generated Method | Description |
//! |-------|------------------|-------------|
//! | `PartialEq` | `static equals(a, b): boolean` | Field-by-field equality comparison |
//! | `Hash` | `static hashCode(value): number` | Hash code generation for collections |
//!
//! ### Ordering
//!
//! | Macro | Generated Method | Description |
//! |-------|------------------|-------------|
//! | `PartialOrd` | `static compareTo(a, b): number \| null` | Partial ordering (can return null) |
//! | `Ord` | `static compareTo(a, b): number` | Total ordering (never null) |
//!
//! ### Cloning & Debugging
//!
//! | Macro | Generated Method | Description |
//! |-------|------------------|-------------|
//! | `Clone` | `static clone(value): T` | Deep copy of the object |
//! | `Debug` | `static toString(value): string` | Human-readable debug representation |
//!
//! ### Initialization
//!
//! | Macro | Generated Method | Description |
//! |-------|------------------|-------------|
//! | `Default` | `static defaultValue(): T` | Factory method with default values |
//!
//! ### Serialization (Serde)
//!
//! | Macro | Generated Method | Description |
//! |-------|------------------|-------------|
//! | `Serialize` | `toJSON(): Record<string, unknown>` | JSON serialization |
//! | `Deserialize` | `static fromJSON(json): T` | JSON deserialization with validation |
//!
//! ## Field-Level Decorators
//!
//! Most macros support field-level decorators to customize behavior:
//!
//! ```typescript
//! /** @derive(Debug, PartialEq, Serialize) */
//! class User {
//! /** @debug({ rename: "identifier" }) */
//! id: number;
//!
//! /** @partialEq({ skip: true }) @serde({ skipSerializing: true }) */
//! password: string;
//!
//! /** @serde({ rename: "emailAddress" }) */
//! email: string;
//! }
//! ```
//!
//! ## Example Usage
//!
//! ```typescript
//! /** @derive(Debug, Clone, PartialEq, Hash) */
//! class Point {
//! x: number;
//! y: number;
//!
//! constructor(x: number, y: number) {
//! this.x = x;
//! this.y = y;
//! }
//! }
//! ```
/// Clone macro implementation (deep copy).
/// Shared utilities for comparison macros.
/// Debug macro implementation (toString).
/// Default macro implementation (factory method).
/// Hash macro implementation (hashCode).
/// Ord macro implementation (total ordering).
/// PartialEq macro implementation (equals).
/// PartialOrd macro implementation (partial ordering).
/// Serialization macros (Serialize, Deserialize).
/// Return type code generation helpers for Deserialize and PartialOrd macros.