Crate codespawn [] [src]

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.

Currently it's possible to generate enums, structs, functions, function pointers, variables and bitflags with all applicable attributes and properties.

See example XML for instructions on how to construct the API definition.

Quick Start

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().unwrap().to_string();
    let rust_code = raw_code.to_rust().unwrap().to_string();

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

Modules

error

Error type for codespawn crate.

fmt_code

Structures and formatters for language-specific code data.

raw_code

Structures and generators for abstract code data.

Functions

from_json

Reads JSON data from file and compiles it into RawCode

from_json_str

Reads JSON data from a &str and compiles it into RawCode

from_xml

Reads XML data from file and compiles it into RawCode

from_xml_str

Reads XML data from a &str and compiles it into RawCode