How brightify/cuckoo works
Main Components Overview
a) Generator (Cuckoonator):
• Input processor for Swift source files
• Syntax analyzer
• Mock code generator
• File output manager
b) Runtime:
• Mock implementation
• Stubbing system
• Verification system
• Matching system
• OCMock integration
Detailed Component Breakdown
Generator Component:
┌─────────────── Generator ───────────────┐
• ┌─────────┐ ┌────────┐ ┌───────┐ │
• Input │ │ Syntax │ │ Token │ │
• Crawler │───▶│Parser │──▶│Parser │ │
• ┘ └────────┘ └───────┘ │
• ▲ │ │
• ▼ │
• ┌─────────┐ ┌────────────────────┐ │
• File │ │ Templates │ │
• Handler │◀───│ - Mock │ │
• ┘ │ - Stub │ │
• Verification │ │
• ┘ │
• ┘
Runtime Component:
┌─────────────── Runtime ────────────────┐
• ┌─────────┐ ┌────────┐ ┌───────┐ │
• Mock │ │ Stub │ │Verify │ │
• Manager │───▶│System │──▶│System │ │
• ┘ └────────┘ └───────┘ │
• ▲ ▲ │
• ┌─────────┐ ┌────────┐ │ │
• Matcher │ │OCMock │ │ │
• System │────│Bridge │──────┘ │
• ┘ └────────┘ │
• ┘
Data Flow and Interactions
┌─────────┐ ┌──────────┐ ┌─────────┐
• Swift │ │Generator │ │Generated │
• Files │────▶│ Process │────▶│ Mocks │
• ┘ └──────────┘ └─────────┘
• ▼
┌─────────┐ ┌──────────┐ ┌─────────┐
• Test │ │ Runtime │ │ Mock │
• Cases │◀───▶│ System │◀────│ Classes │
• ┘ └──────────┘ └─────────┘
The integration with external systems (OCMock, build system)
This system design captures the complexity of Cuckoo while making it clear how the different parts work together to provide a complete mocking solution for Swift.