Skip to content

xaliphostes/rosetta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Rosetta β€” A C++ Introspection & Automatic Language Binding

One registration, infinite possibilities πŸš€

Logo rosetta

Linux support macOS support Windows support
Language License

With support to:

Python support
JavaScript support
Emscripten support
REST API support
Qt support
ImGui support
Lua support
Java support
Ruby support
Julia support


🧩 Overview

Rosetta is a non-intrusive C++ header-only introspection library that is used to automatically generates consistent bindings for Python, JavaScript, Lua, Ruby, Julia and more β€” without modifying your C++ code.

Describe your introspection once, and export them everywhere. You do not need to know anything about the underlaying libs that are used for the bindings (NAPI, Pybind11, Rice...)

Examples

  • CGAL-rosetta based on the CGAL library, for 3D surfaces intersections and remeshing

    Logo rosetta
  • PMP-rosetta based on the PMP library, for decimation, remeshing, subdivision or smoothing

    Logo rosetta
  • Arch-rosetta based on the Arch library, the successor of Poly3D from Stanford and iBem3D from slb, a 3D Boundary Element Method in geomechanics

    Logo rosetta

🧩 Usages

  1. C++ Introspection
  2. Generator for scripting languages
    • Python
    • JavScript
    • WebAssembly
    • TypeScript
    • Rest API
    • ...
  3. Property editor (GUI)
    • Qt
    • ImGui
  4. Serialization
  5. Undo/redo framework
  6. Documentation generation in Markdown
  7. Validation on field or property (range...)

✨ Features

  1. Zero-intrusion β€” No inheritance, no macros inside your classes, no wrapper
  2. Simple to use
  3. One API -> Multi-language output β€” Python (pybind11), JavaScript (N-API), Lua, WASM...
  4. Supports:
    • Multiple constructors
    • Inheritance & polymorphism β€” Virtual methods, multiple inheritance
    • Const correctness β€” Differentiates const/non-const methods
    • Method Complete Overload Access
    • Synthetic Methods - methods to classes that don't exist in the original C++ class definition.
    • Functors
    • Fields - Member variables
    • Virtual fields (property) - From setDummy/getDummy methods, create the virtual field dummy
    • Static methods
    • Free functions
    • STL Containers β€” vector, map, set, array, etc... of any type
    • Smart pointers β€” shared_ptr, unique_ptr, raw pointers
  5. Validation system β€” Runtime constraints and checks
  6. Serialization
  7. Documentation generation β€” Markdown / HTML export
  8. Qt Integration β€” QML bridge for dynamic property editing, automatic property editor widgets
  9. Undo/Redo extension - Generic undo/redo manager for tracking and reverting property/field changes

πŸ“Š Comparison with Other Systems

Feature Rosetta Qt MOC RTTR Boost.Describe
Non-intrusive βœ… ❌ βœ… βœ…
No macros in class βœ… ❌ ❌ ❌
Header-only βœ… ❌ ❌ βœ…
Static methods βœ… βœ… βœ… ⚠️
Virtual methods βœ… βœ… βœ… ❌
Free functions βœ… ❌ βœ… ❌
Python bindings βœ… βœ… ⚠️ ❌
JavaScript bindings βœ… ❌ ❌ ❌
WebAssembly bindings βœ… ❌ ❌ ❌
REST API generation βœ… ❌ ❌ ❌
Serialization βœ… βœ… βœ… ⚠️
Qt integration βœ… βœ… ⚠️ ❌

Legends

Symbol Meaning Description
βœ… Fully Supported Feature is implemented, stable, and works as expected
⚠️ Partial Support Feature exists but has limitations, requires workarounds, or is incomplete
❌ Not Supported Feature is not available or not applicable
🚧 In Progress Feature is being developed or planned

πŸš€ Short overview

1. Your lib

class Vector3D {...};
class SceneManager {...};
...

along with a static or dynamic library or nothing (if headers only).

2. Describe your API with Rosetta and generate the binding for any language

This description provide the introspection of your classes that will be used by the generators (see below).

#include <rosetta/rosetta.h>
#include <yourlib/all.h>

void rosetta_registration() {
    ROSETTA_REGISTER_CLASS(Vector3D)
        .field("z", &Vector3D::z)
        .method("length", &Vector3D::length)
        .method("normalize", &Vector3D::normalize);

    ROSETTA_REGISTER_CLASS(SceneManager)
        .method("add", &SceneManager::add)
        ...;
}

3. Generate the binding for any language (Python, JavaScript, TypeScript, Wasm, REST-API...)

Since the introspection of your C++ classes (and free functions) is now created by Rosetta, binding is straightforward as long as the generator for a given language is available. To generate a rosetta skeleton for your project, use this tool, a project scaffolding tool for creating Rosetta binding projects.

Read this tuto and have a look at this example for how to use the generators in combination with Rosetta.

Also, for more complex examples, see (1) this project, (2) this one or (3) this one.

πŸ–ΌοΈ Qt Integration

Rosetta provides seamless Qt6 integration with two complementary components:

QML Bridge

The QmlBridge class exposes Rosetta-registered objects to QML, enabling dynamic property editing without compile-time type knowledge:

QmlBridge {
    id: bridge
}

// Bind any Rosetta-registered object
bridge.setObject("MyClass", myObject)

// Dynamically access fields and methods
var value = bridge.getField("position")
bridge.setField("scale", 2.0)
bridge.invokeMethod("reset", [])

Automatic Property Editor

Properties Methods

Generate Qt widgets automatically from your Rosetta-registered classes:

#include <rosetta/extensions/qt/qt_property_editor.h>
#include <rosetta/rosetta.h>

class Person {...};

static auto reg = []() {
    rosetta::core::Registry::instance()...
}();

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);

    Person person;

    auto *inspector = new rosetta::qt::ObjectInspector<Person>(&person);
    inspector->setWindowTitle("Person Inspector");
    inspector->resize(300, 400);
    inspector->show();

    return app.exec();
}

The property editor supports:

  • Automatic widget generation β€” Spinboxes for numbers, checkboxes for bools, line edits for strings
  • Custom widget registration β€” Sliders, color pickers, file selectors, combo boxes
  • Grouped properties β€” Organize fields into collapsible sections
  • Multi-object editing β€” Edit multiple objects simultaneously
  • Method invocation β€” Button panels for calling registered methods
  • Undo/redo support β€” Track property changes for reversible editing

πŸ–ΌοΈ ImGui Integration

Rosetta provides seamless ImGui integration with its PropertyEditor for fields and methods

Properties

πŸ’‘ Contribute Your Own Generator or Extension

You're very welcome to create a generator based on Rosetta introspection for other scripting languages β€” such as Lua, Julia, or Ruby!

Also, any extension is welcome ;-)

πŸ‘‰ Check out this folder to see the existing Python, JavaScript, Wasm and REST API generators for inspiration.

Every new generator or extension helps expand the ecosystem β€” contributions are always greatly appreciated ❀️

πŸ“œ License

LGPL 3 License β€” see LICENSE


πŸ’‘ Credits

Xaliphostes (fmaerten@gmail.com)

About

A C++ hearders only for automatic language binding

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published