8000 GitHub - Jomy10/Octo: Polyglot binding generator: Generate bindings from language X to language Y
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Jomy10/Octo

Repository files navigation

Octo

A polyglot binding generator

Warning

This program is currently in early development. Not all features are currently functional. Unexpected things may happen.

Use case

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.

Installation

  • The program and parser and generator libraries require building from source and manual installation at this moment.

Building

prerequisites

  • 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

Building

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

Running tests

ruby build.rb all

ruby build.rb test
# OR, for clearer output:
ruby test-report.rb

Examples

Examples can be found in:

  • the examples directory
  • additional examples can be found in the tests

Plugins

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

Official plugins

Currently, the following languages are implemented:

Parsers

  • C

Generators

  • Ruby
  • C

Goals

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

About

Polyglot binding generator: Generate bindings from language X to language Y

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published
0