Commit d14295f3 authored by Jeremy Soller's avatar Jeremy Soller Committed by GitHub

Merge pull request #2 from dlrobertson/redox_master

Pull in upstream changes
parents fe26d47a 6fea38f1
This diff is collapsed.
[package]
name = "cbindgen"
version = "0.5.1"
version = "0.5.2"
authors = ["Jeff Muizelaar <jmuizelaar@mozilla.com>",
"Kartikaya Gupta <kats@mozilla.com>",
"Ryan Hunt <rhunt@eqrion.net>"]
......@@ -21,10 +21,13 @@ serde = {version = "1.0", features = ["derive"]}
serde_json = "1.0"
tempdir = "0.3"
toml = "0.4"
# Workaround for #147
serde_derive = "=1.0.21"
[dependencies.standalone-syn]
version = "0.12.10"
features = ["extra-traits", "full"]
version = "0.13.0"
default-features = false
features = ["clone-impls", "derive", "extra-traits", "full", "parsing", "printing"]
[[bin]]
name = "cbindgen"
......
......@@ -9,8 +9,6 @@
This project can be used to generate C bindings for Rust code. It is currently being developed to support creating bindings for [WebRender](https://github.com/servo/webrender/), but has been designed to support any project.
Note: `cbindgen` temporarily requires `nightly`. See `#147` for information and current status.
## Features
* Builds bindings for a crate, its mods, its dependent crates, and their mods
......
......@@ -8,7 +8,7 @@ use std::mem;
use syn;
use bindgen::config::{Config, Language};
use bindgen::ir::{AnnotationSet, Cfg, Documentation, Item, ItemContainer, Type};
use bindgen::ir::{AnnotationSet, Cfg, CfgWrite, Documentation, Item, ItemContainer, Type};
use bindgen::ctyperesolver::CTypeResolver;
use bindgen::writer::{Source, SourceWriter};
......@@ -137,6 +137,7 @@ impl Item for Constant {
impl Source for Constant {
fn write<F: Write>(&self, config: &Config, out: &mut SourceWriter<F>) {
self.cfg.write_before(config, out);
if config.constant.allow_static_const && config.language == Language::Cxx {
if let Type::ConstPtr(..) = self.ty {
out.write("static ");
......@@ -148,5 +149,6 @@ impl Source for Constant {
} else {
write!(out, "#define {} {}", self.name, self.value.0)
}
self.cfg.write_after(config, out);
}
}
......@@ -2,6 +2,14 @@
#include <stdlib.h>
#include <stdbool.h>
#if defined(NOT_DEFINED)
#define DEFAULT_X 8
#endif
#if defined(DEFINED)
#define DEFAULT_X 42
#endif
#if (defined(NOT_DEFINED) || defined(DEFINED))
typedef struct {
int32_t x;
......
#include <cstdint>
#include <cstdlib>
#if defined(NOT_DEFINED)
static const int32_t DEFAULT_X = 8;
#endif
#if defined(DEFINED)
static const int32_t DEFAULT_X = 42;
#endif
#if (defined(NOT_DEFINED) || defined(DEFINED))
struct Foo {
int32_t x;
......
......@@ -21,6 +21,12 @@ struct Root {
w: Bar,
}
#[cfg(windows)]
pub const DEFAULT_X: i32 = 0x08;
#[cfg(unix)]
pub const DEFAULT_X: i32 = 0x2a;
#[no_mangle]
pub extern "C" fn root(a: Root)
{ }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment