codespawn 0.1.0

C++ and Rust code generator
Documentation

Codespawn

Crates.io Build Status Build status Coverage Status

Codespawn is a basic C++ and Rust code generator. Desired API can be defined using either JSON or XML and the crate supports both reading from a file or a string. As of 0.1 release, it's possible to generate enums, structs, functions and variables with all applicable attributes and properties.

Initially, this crate was created as a helper tool for ProDBG.

Documentation

Usage

# Cargo.toml
[dependencies]
codespawn = "0.1"

Example

extern crate codespawn;

fn main()
{
    // generate from XML definition
    let raw_code = codespawn::from_xml("examples/sample.xml").unwrap();
    // generate from JSON definition
    //let raw_code = codespawn::from_json("examples/sample.json").unwrap();

    // generate code, store as String
    let cpp_code  = raw_code.to_cpp().to_string();
    let rust_code = raw_code.to_rust().to_string();

    // generate and save directly to file
    raw_code.to_cpp().to_file("sample.cpp");
    raw_code.to_rust().to_file("sample.rs");
}

Build instructions

cargo build
cargo run --example xml

This will run the example which will generate code and save it to files using sample XML definition.

License

Licensed under either of