Giter VIP home page Giter VIP logo

rtps-gen's Introduction

Apache 2.0 licensed

RTPS IDL to Rust code generator

A tool reading an IDL and generating corresponding Rust code.

Usage:

rtps-gen -I <include-dir> data.idl -o output.rs

RTPS-IDL to Rust Mapping

The IDL types are mapped onto Rust as follows. If a type-mapping has not been decided, it is marked with 'NA'.
As RTPS is a data-centric framework in contrast to the the original OO background, the focus is put onto data structures, and ignoring interfaces and structures so far.

IDL-Type Rust-Type
module module
boolean bool
char/wchar char
octet u8
string/wstring std::string::String
short i16
long i32
long long i64
unsigned short u16
unsigned long u32
unsigned long long u64
float f32
double f64
fixed NA
enum enum
union enum
struct struct
sequence std::vec::Vec
array, eg. 'T a[N]' native array '[T;N]'
interface (non abstract) NA
interface (abstract) NA
constant (not within interface) const
constant (within an interface) NA
exception std::result::Result
Any NA
type declarations nested within interfaces NA
typedef type
pseudo objects NA
readonly attribute NA
readwrite attribute NA
operation NA

Mapping by examples

Templates

IDL Rust
sequence<octet> std::vec::Vec<u8>

Typedef

IDL Rust
typedef long Foo; pub type Foo = i32;
typedef short Foo[2]; pub type Foo = [i16;2]
typedef short Foo[2][3]; pub type Foo = [[i16; 2]; 3]
typedef sequence Foo; pub type Foo = std::vec::Vec

Struct

IDL Rust
struct Foo {
 long l;
 short s;
};
pub struct Foo {
 pub l: i32,
 pub s: i16;
}

Enum

IDL Rust
enum Foo { VARIANT0, VARIANT1, VARIANT2 }; pub enum Foo { VARIANT0, VARIANT1, VARIANT2, }

Union Switch

Note: Only switch types "switch (long)" is supported yet.

IDL Rust
union Foo switch (long) {
 case LABEL0: long l;
 case LABEL1:
 case LABEL2: short s;
 default: octet o[8];
};
pub enum Foo {
 LABEL0{l: i32},
 LABEL2{s: i16},
 LABEL1{s: i16},
 default{o: [u8; 8]},
}
/* not yet, to be developed */
union Result switch (long) {
 case None: void _dummy;
 case Some: T t
};
/* not yet, to be developed */
pub enum Result<T> {
 None,
 Some(T),
}

rtps-gen's People

Contributors

frehberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rtps-gen's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.