Show HN: Mirror_bridge โ€“ C++ Reflection powered Python binding generation

https://news.ycombinator.com/rss Hits: 3
Summary

Mirror Bridge Modern C++ meets Multiple Languages: Automatic bindings using C++26 reflection - zero boilerplate, pure compile-time magic. โš ๏ธ EXPERIMENTAL: This project requires C++26 reflection (P2996), which is not yet standardized. It only works with Bloomberg's clang-p2996 fork. Not recommended for production use until P2996 lands in standard C++26. One C++ Class, Three Languages // Write your C++ code once struct Calculator { double value = 0.0 ; double add ( double x) { return value += x; } double subtract ( double x) { return value -= x; } }; Python: import cpp_calc calc = cpp_calc . Calculator () calc . add ( 10 ) calc . subtract ( 3 ) print ( calc . value ) # 7.0 JavaScript (Node.js): const calc = new addon . Calculator ( ) ; calc . add ( 10 ) ; calc . subtract ( 3 ) ; console . log ( calc . x ) ; // 7.0 Lua: local calc = cpp_calc . Calculator () calc : add ( 10 ) calc : subtract ( 3 ) print ( calc . value ) -- 7.0 No manual binding code. No wrapper macros. Just pure C++26 reflection. ๐ŸŽ‰ Supported Languages Language Status API Example Python โœ… Stable Python C API import my_module JavaScript โœ… Stable Node.js N-API const mod = require('my_module') Lua โœ… Stable Lua C API local mod = require("my_module") What is Mirror Bridge? Mirror Bridge is a header-only library that uses C++26 reflection (P2996) to automatically introspect your C++ classes at compile-time and generate bindings for Python, JavaScript, and Lua. It discovers: โœ… Data members - automatic getters/setters with type safety - automatic getters/setters with type safety โœ… Methods (any number of parameters) - variadic parameter support (any number of parameters) - variadic parameter support โœ… Constructors - including parameterized constructors - including parameterized constructors โœ… Method overloading - automatic name mangling for overloads - automatic name mangling for overloads โœ… Smart pointers - std::unique_ptr , std::shared_ptr with automatic conversion - , with automatic conversion โœ… Nested classes...

First seen: 2025-12-04 08:07

Last seen: 2025-12-04 10:08