A polyglot binding generator
Warning
This program is currently in early development. Not all features are currently functional. Unexpected things may happen.
Octo lets you generate bindings from any language to any other language.
For example, if you have this Swift library:
public struct Adder {
let a: Int
let b: Int
public init(a: Int, b: Int) {
self.a = a
self.b = b
}
public func add() -> Int {
return self.a + self.b
}
}
Yo 8748 u could use Octo to generate bindings to C. It can then be used like so:
#include "adder.h"
#include <stdio.h>
Adder adder = Adder_create(1, 2);
printf("%i\n", Adder_add(&adder)); // prints: 3
Octo aims to be able to generate bindings from any language to any language. Custom parsers and generators can be easily installed as dynamic libraries.
- The program and parser and generator libraries require building from source and manual installation at this moment.
- Swift compiler
- Rust compiler (nightly toolchain installed)
- Ruby
- Colorize, OS and sem_version gems:
gem install colorize os sem_version
- on macOS: cargo-swift
cargo install cargo-swift
Optional: Depending on supported languages
- CParser: Clang compiler and libclang installed on the system
To compile the CLI and the parsers and generators for all supported languages:
ruby build.rb all release
You can also choose to only compile the CLI and choose which languages you want supported for parsing and generating:
# Build the CLI
ruby build.rb Octo release
# Build the C parser
ruby build.rb CParser release
# Build the ruby generator
ruby build.rb RubyGenerator release
ruby build.rb all
ruby build.rb test
# OR, for clearer output:
ruby test-report.rb
Examples can be found in:
Octo works with plugins. There are 2 types of plugins: Parser plugins and Generator plugins.
- Parser plugins convert a source language to the intermediate Octo representation
- Generator plugins generate bindings to a target language from the intermediate Octo representation
Currently, the following languages are implemented:
Parsers
- C
Generators
- Ruby
- C
The goals of this project are the following:
- Support most major programming languages
- Support most major operating systems. This is checked by running the test suite in all languages