mozilla/rust — Issue #1735: Native modules do not support const, enum and type properly.
Author: beoran
Created: 2012-02-02 11:54:11+00:00
State: open

When playing around with rust 0.1 and trying to wrap Allegro, a game programming library with it I noticed that it's not possible to use enum , or const in a native module . This is annoying since it means I have to use a second non-native module to define the C constants and enums that Allegro uses. Also, type doesn't work well, so again, I have to use another non-native module to define the struct types for Allegro. Could all this be allowed in the future?

Below is an example rewritten for libc:

```rust
use std;
import std::io;

mod libc1_nn {
enum test { zero, one, two, three }
}

#[nolink]
native mod libc1 {
enum test { zero, one, two, three }
}

mod libc2_nn {
const constant : int = 10;
}

#[nolink]
native mod libc2 {
const constant : int = 10;
}

mod libc3_nn {
type rec = { a : c_int , b : c_int };
}

#[nolink]
native mod libc3 {
import ctypes::*;
type rec = { a : c_int , b : c_int };
}
```