{"id":35157566,"url":"https://github.com/captkirk88/zevy-reflect","last_synced_at":"2026-05-19T08:11:40.322Z","repository":{"id":328093615,"uuid":"1111306069","full_name":"captkirk88/zevy-reflect","owner":"captkirk88","description":"A reflection library in Zig with utilities covering change detection and interface validation and vtable generation using real structs.  Mixin generation and generic Generator (OOP in zig)","archived":false,"fork":false,"pushed_at":"2026-05-18T21:08:11.000Z","size":261,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-18T23:43:45.779Z","etag":null,"topics":["mixin","oop","reflection","zevy","zig","zig-library","zig-package","zig-programming-language","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/captkirk88.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-06T17:17:08.000Z","updated_at":"2026-05-18T21:08:14.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/captkirk88/zevy-reflect","commit_stats":null,"previous_names":["captkirk88/zevy-reflect"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/captkirk88/zevy-reflect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/captkirk88%2Fzevy-reflect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/captkirk88%2Fzevy-reflect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/captkirk88%2Fzevy-reflect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/captkirk88%2Fzevy-reflect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/captkirk88","download_url":"https://codeload.github.com/captkirk88/zevy-reflect/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/captkirk88%2Fzevy-reflect/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33207798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-19T07:54:09.561Z","status":"ssl_error","status_checked_at":"2026-05-19T07:54:08.508Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mixin","oop","reflection","zevy","zig","zig-library","zig-package","zig-programming-language","ziglang"],"created_at":"2025-12-28T17:04:20.247Z","updated_at":"2026-05-19T08:11:40.317Z","avatar_url":"https://github.com/captkirk88.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zevy-reflect\n\nA lightweight reflection and change detection library for Zig.\n\n[![Zig Version](https://img.shields.io/badge/zig-0.16.dev+-blue.svg)](https://ziglang.org/)\n\n## Features\n\n- **Runtime Type Information**: Get detailed type information at runtime including fields, functions, and nested types\n- **Interface Validation**: Compile-time validation of interface implementations with clear error messages\n    - **VTable Generation**: Create vtables for dynamic dispatch based on interfaces, with support for interface extension. Tested using std.mem.Allocation.VTable interface.\n- **Function Verification**: Compile-time validation of function signatures with dynamic error reporting for type mismatches\n- **Dynamic Error Types**: Utilities for creating error sets with dynamic names at comptime\n- **Code Generation Contracts**: Build reusable compile-time generators with typed input and config validation\n- **Mixin Generation**: Generate new types by mixing two existing types together (supports mixin types chaining), with configurable conflict resolution strategies\n- **Change Detection**: Track changes to struct fields with minimal memory overhead (8 bytes)\n- **Zero Dependencies**: Pure Zig implementation with no external dependencies\n\n## Installation\n\nAdd to your `build.zig.zon`:\n\n```bash\nzig fetch --save git+https://github.com/captkirk88/zevy-reflect\n```\n\nThen in your `build.zig`:\n\n```zig\nconst zevy_reflect = b.dependency(\"zevy_reflect\", .{});\nexe.root_module.addImport(\"zevy_reflect\", zevy_reflect.module(\"zevy_reflect\"));\n```\n\n## Quick Start\n\n### Reflection\n\nThis library provides both lightweight (shallow) runtime `ReflectInfo` and a small set of helpers to query type structure.\n\n```zig\nconst reflect = @import(\"zevy_reflect\");\nconst std = @import(\"std\");\n\nconst MyStruct = struct {\n    id: u32,\n    name: []const u8,\n    active: bool,\n\n    pub fn getId(self: @This()) u32 { return self.id; }\n};\n\ncomptime {\n    const info = reflect.getReflectInfo(MyStruct);\n    std.debug.print(\"Name: {s}, Size: {d}\\n\", .{ info.name, info.size });\n\n    // Field checks (comptime-safe helpers):\n    try std.testing.expect(comptime reflect.hasField(MyStruct, \"id\"));\n    try std.testing.expect(comptime reflect.hasFunc(MyStruct, \"getId\"));\n\n    // List field names at comptime\n    const fields = reflect.getFields(MyStruct);\n    inline for (fields) |f| std.debug.print(\"field: {s}\\n\", .{ f });\n}\n\n// Runtime: use ReflectInfo to introspect dynamic metadata\nconst ti = reflect.getReflectInfo(MyStruct);\nstd.debug.print(\"Runtime fields: {d}\\n\", .{ ti.fields.len });\n```\n\nNotes:\n- `getReflectInfo` returns shallow field and function metadata suitable for runtime use.\n\n### Utilities\n\nThe library provides various utility functions for advanced reflection and error handling:\n\n```zig\nconst reflect = @import(\"zevy_reflect\");\n\n// Create dynamic error sets\nconst MyError = reflect.utils.DynamicError(\"CustomError\");\nconst err = MyError.CustomError;\n\n// Append errors to existing sets\nconst ExtendedError = reflect.utils.MergeDynamicError(error{ Base }, \"Dynamic\");\n\n// Verify function signatures with detailed type mismatch errors\ncomptime {\n    try std.testing.expect(comptime reflect.verifyFuncWithArgs(MyStruct, \"getId\", \u0026[_]type{}, null) catch false);\n    // Type mismatches generate specific errors like \"IncorrectArgAt_0_Expected_i32_Got_f32\"\n}\n```\n\n### Code Generation\n\nSee [MIXIN_CODEGEN.md](MIXIN_CODEGEN.md) for the mixin-specific API.\n\n### Interface Validation and VTable\n\n`Template(...)` provides a compile-time validator and a typed vtable generator. Useful when you want an explicit interface and a vtable for dynamic dispatch. `Template(...).Interface` is the interface type.\n\nIf you want validation errors to include the user callsite that triggered validation, use `Template(...).validateAt(Impl, @src())` or `validateVerboseAt(Impl, @src())`.\n\n```zig\n\nThis is a different approach to interfaces in Zig.  Hopefully more useful and generally easier to integrate.\n\nSee [common_interfaces.zig](src/common_interfaces.zig) for a examples.\n\n### Change Detection\n\n`Change(T)` is a tiny tracker that hashes trackable fields and detects modifications. Fields beginning with `_` are ignored.\n\n```zig\nconst reflect = @import(\"zevy_reflect\");\nconst std = @import(\"std\");\n\nconst Player = struct {\n    health: i32,\n    score: u32,\n    _internal_id: u64, // ignored by Change\n};\n\nvar player = Player{ .health = 100, .score = 0, ._internal_id = 123 };\nvar tracker = reflect.Change(Player).init(player);\n\n// Mutate through `get()` (mutable) and finish when processed\nvar data = tracker.get();\ndata.health = 80;\ndata.score = 100;\n\nif (tracker.isChanged()) {\n    std.debug.print(\"Player changed: {d}\\n\", .{ tracker.getConst().score });\n    tracker.finish();\n}\n```\n\n\u003e [!WARNING]\n\u003e The tracker compares raw bytes for tracked fields; pointer/slice/array contents are hashed as their pointer/length/contents as appropriate. Be cautious with non-stable data (e.g., transient pointers).\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Add tests for any new functionality\n4. Ensure all tests pass: `zig build test`\n5. Submit a pull request\n\n## Related Projects\n\n- [zevy-ecs](https://github.com/captkirk88/zevy-ecs) - Entity Component System framework that uses zevy-reflect.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaptkirk88%2Fzevy-reflect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaptkirk88%2Fzevy-reflect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaptkirk88%2Fzevy-reflect/lists"}