No bug - Revendor rust dependencies

This commit is contained in:
Servo VCS Sync 2017-06-21 02:15:52 +00:00
Родитель 0c0590d8ce
Коммит 3167c35036
18 изменённых файлов: 238 добавлений и 182 удалений

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

31
third_party/rust/bindgen/CONTRIBUTING.md поставляемый
Просмотреть файл

@ -10,6 +10,7 @@ out to us in a GitHub issue, or stop by
- [Code of Conduct](#code-of-conduct)
- [Filing an Issue](#filing-an-issue)
- [Looking to Start Contributing to `bindgen`?](#looking-to-start-contributing-to-bindgen)
- [Building](#building)
- [Testing](#testing)
- [Overview](#overview)
@ -18,6 +19,7 @@ out to us in a GitHub issue, or stop by
- [Authoring New Tests](#authoring-new-tests)
- [Test Expectations and `libclang` Versions](#test-expectations-and-libclang-versions)
- [Automatic code formatting](#automatic-code-formatting)
- [Pull Requests and Code Reviews](#pull-requests-and-code-reviews)
- [Generating Graphviz Dot Files](#generating-graphviz-dot-files)
- [Debug Logging](#debug-logging)
- [Using `creduce` to Minimize Test Cases](#using-creduce-to-minimize-test-cases)
@ -37,12 +39,18 @@ We abide by the [Rust Code of Conduct][coc] and ask that you do as well.
Think you've found a bug? File an issue! To help us understand and reproduce the
issue, provide us with:
* A (preferrably reduced) C/C++ header file that reproduces the issue
* A (preferably reduced) C/C++ header file that reproduces the issue
* The `bindgen` flags used to reproduce the issue with the header file
* The expected `bindgen` output
* The actual `bindgen` output
* The [debugging logs](#logs) generated when running `bindgen` on this testcase
## Looking to Start Contributing to `bindgen`?
* [Issues labeled "easy"](https://github.com/servo/rust-bindgen/issues?q=is%3Aopen+is%3Aissue+label%3AE-easy)
* [Issues labeled "less easy"](https://github.com/servo/rust-bindgen/issues?q=is%3Aopen+is%3Aissue+label%3AE-less-easy)
* Still can't find something to work on? [Drop a comment here](https://github.com/servo/rust-bindgen/issues/747)
## Building
To build the `bindgen` library and the `bindgen` executable:
@ -176,6 +184,27 @@ $ cargo fmt
The code style is described in the `rustfmt.toml` file in top level of the repo.
## Pull Requests and Code Reviews
Ensure that each commit stands alone, and passes tests. This enables better `git
bisect`ing when needed. If your commits do not stand on their own, then rebase
them on top of the latest master and squash them into a single commit.
All pull requests undergo code review before merging. To request review, comment
`r? @github_username_of_reviewer`. They we will respond with `r+` to approve the
pull request, or may leave feedback and request changes to the pull request. Any
changes should be squashed into the original commit.
Unsure who to ask for review? Ask any of:
* `@emilio`
* `@fitzgen`
More resources:
* [Servo's GitHub Workflow](https://github.com/servo/servo/wiki/Github-workflow)
* [Beginner's Guide to Rebasing and Squashing](https://github.com/servo/servo/wiki/Beginner's-guide-to-rebasing-and-squashing)
## Generating Graphviz Dot Files
We can generate [Graphviz](http://graphviz.org/pdf/dotguide.pdf) dot files from

70
third_party/rust/bindgen/Cargo.toml поставляемый
Просмотреть файл

@ -12,7 +12,7 @@
[package]
name = "bindgen"
version = "0.25.5"
version = "0.26.1"
authors = ["Jyun-Yan You <jyyou.tw@gmail.com>", "Emilio Cobos Álvarez <emilio@crisal.io>", "Nick Fitzgerald <fitzgen@gmail.com>", "The Servo project developers"]
build = "build.rs"
exclude = ["bindgen-integration", "ci", "tests/**", "*.orig"]
@ -31,37 +31,16 @@ path = "src/lib.rs"
name = "bindgen"
path = "src/main.rs"
doc = false
[dependencies.regex]
version = "0.2"
[dependencies.env_logger]
version = "0.4"
optional = true
[dependencies.peeking_take_while]
version = "0.1.2"
[dependencies.log]
version = "0.3"
optional = true
[dependencies.clap]
version = "2"
[dependencies.quasi]
version = "0.32"
features = ["with-syntex"]
[dependencies.lazy_static]
version = "0.2.1"
[dependencies.cexpr]
version = "0.2"
[dependencies.aster]
version = "0.41"
features = ["with-syntex"]
[dependencies.cfg-if]
version = "0.1.0"
[dependencies.clang-sys]
version = "0.18.0"
features = ["runtime", "clang_3_9"]
@ -69,27 +48,48 @@ features = ["runtime", "clang_3_9"]
[dependencies.syntex_syntax]
version = "0.58"
[dependencies.cfg-if]
version = "0.1.0"
[dependencies.regex]
version = "0.2"
[dependencies.peeking_take_while]
version = "0.1.2"
[dependencies.cexpr]
version = "0.2"
[dependencies.quasi]
version = "0.32"
features = ["with-syntex"]
[dependencies.env_logger]
version = "0.4"
optional = true
[dependencies.clap]
version = "2"
[dependencies.log]
version = "0.3"
optional = true
[dev-dependencies.shlex]
version = "0.1"
[dev-dependencies.diff]
version = "0.1"
[dev-dependencies.clap]
version = "2"
[dev-dependencies.shlex]
version = "0.1"
[build-dependencies.quasi_codegen]
version = "0.32"
[features]
logging = ["env_logger", "log"]
testing_only_libclang_3_8 = []
testing_only_libclang_4 = []
testing_only_extra_assertions = []
static = []
testing_only_docs = []
testing_only_libclang_3_8 = []
testing_only_libclang_3_9 = []
default = ["logging"]
testing_only_libclang_4 = []
testing_only_libclang_3_9 = []
testing_only_docs = []
logging = ["env_logger", "log"]
[badges.travis-ci]
repository = "servo/rust-bindgen"

Просмотреть файл

@ -22,10 +22,6 @@ fn main() {
// to bindgen, and lets you build up options for
// the resulting bindings.
let bindings = bindgen::Builder::default()
// Do not generate unstable Rust code that
// requires a nightly rustc and enabling
// unstable features.
.no_unstable_rust()
// The input header we would like to generate
// bindings for.
.header("wrapper.h")

Просмотреть файл

@ -1,6 +1,8 @@
# Using the Union Types Generated by Bindgen
**NOTE:** As of Rust version 1.17, Rust does not have a stable `union` type. Issue [#32836](https://github.com/rust-lang/rust/issues/32836) tracks the stabilization of a `union` type in Rust. By default, bindgen will generate the preliminary unstable `union` type, unless the flag `--no-unstable-rust` flag is used.
**NOTE:** As of Rust version 1.17, Rust does not have a stable `union` type. Issue [#32836](https://github.com/rust-lang/rust/issues/32836) tracks the stabilization of a `union` type in Rust.
By using the flag `--unstable-rust`, bindgen will generate the preliminary unstable `union` type.
In general, most interactions with unions (either reading or writing) are unsafe.
@ -29,12 +31,12 @@ typedef union {
### Library
* [`bindgen::Builder::no_unstable_rust()`](https://docs.rs/bindgen/0.25.3/bindgen/struct.Builder.html#method.no_unstable_rust)
* [`bindgen::Builder::unstable_rust()`](https://docs.rs/bindgen/0.25.3/bindgen/struct.Builder.html#method.unstable_rust)
* [`bindgen::Builder::derive_default()`](https://docs.rs/bindgen/0.25.3/bindgen/struct.Builder.html#method.derive_default)
### Command Line
* `--no-unstable-rust`
* `--unstable-rust`
* `--with-derive-default`
## Using the unstable `union` version
@ -129,4 +131,4 @@ error[E0308]: mismatched types
|
= note: expected type `bindings::__BindgenUnionField<bindings::alpha_t>`
found type `bindings::alpha_t`
```
```

70
third_party/rust/bindgen/src/clang.rs поставляемый
Просмотреть файл

@ -1361,55 +1361,31 @@ impl TranslationUnit {
-> Option<Vec<cexpr::token::Token>> {
use cexpr::token;
let mut tokens = match self.tokens(cursor) {
Some(tokens) => tokens,
None => return None,
};
self.tokens(cursor).map(|tokens| {
tokens
.into_iter()
.filter_map(|token| {
let kind = match token.kind {
CXToken_Punctuation => token::Kind::Punctuation,
CXToken_Literal => token::Kind::Literal,
CXToken_Identifier => token::Kind::Identifier,
CXToken_Keyword => token::Kind::Keyword,
// NB: cexpr is not too happy about comments inside
// expressions, so we strip them down here.
CXToken_Comment => return None,
_ => {
error!("Found unexpected token kind: {:?}", token);
return None
}
};
// FIXME(emilio): LLVM 3.9 at least always include an extra token for no
// good reason (except if we're at EOF). So we do this kind of hack,
// where we skip known-to-cause problems trailing punctuation and
// trailing keywords.
//
// This is sort of unfortunate, though :(.
//
// I'll try to get it fixed in LLVM if I have the time to submit a
// patch.
let mut trim_last_token = false;
if let Some(token) = tokens.last() {
// The starting of the next macro.
trim_last_token |= token.spelling == "#" &&
token.kind == CXToken_Punctuation;
// A following keyword of any kind, like a following declaration.
trim_last_token |= token.kind == CXToken_Keyword;
}
if trim_last_token {
tokens.pop().unwrap();
}
Some(tokens.into_iter()
.filter_map(|token| {
let kind = match token.kind {
CXToken_Punctuation => token::Kind::Punctuation,
CXToken_Literal => token::Kind::Literal,
CXToken_Identifier => token::Kind::Identifier,
CXToken_Keyword => token::Kind::Keyword,
// NB: cexpr is not too happy about comments inside
// expressions, so we strip them down here.
CXToken_Comment => return None,
_ => {
panic!("Found unexpected token kind: {:?}", token.kind)
}
};
Some(token::Token {
kind: kind,
raw: token.spelling.into_bytes().into_boxed_slice(),
Some(token::Token {
kind: kind,
raw: token.spelling.into_bytes().into_boxed_slice(),
})
})
})
.collect::<Vec<_>>())
.collect::<Vec<_>>()
})
}
}

75
third_party/rust/bindgen/src/codegen/mod.rs поставляемый
Просмотреть файл

@ -23,7 +23,7 @@ use ir::item_kind::ItemKind;
use ir::layout::Layout;
use ir::module::Module;
use ir::objc::{ObjCInterface, ObjCMethod};
use ir::template::{AsNamed, TemplateInstantiation, TemplateParameters};
use ir::template::{AsTemplateParam, TemplateInstantiation, TemplateParameters};
use ir::ty::{Type, TypeKind};
use ir::var::Var;
@ -641,7 +641,7 @@ impl CodeGenerator for Type {
if let Some(ref params) = used_template_params {
for template_param in params {
if let Some(id) =
template_param.as_named(ctx, &()) {
template_param.as_template_param(ctx, &()) {
let template_param = ctx.resolve_type(id);
if template_param.is_invalid_named_type() {
warn!("Item contained invalid template \
@ -1113,9 +1113,9 @@ impl Bitfield {
#[inline]
$fn_prefix $ctor_name($params $param_name : $bitfield_ty)
-> $unit_field_int_ty {
($body |
(($param_name as $bitfield_int_ty as $unit_field_int_ty) << $offset) &
($mask as $unit_field_int_ty))
($body |
(($param_name as $bitfield_int_ty as $unit_field_int_ty) << $offset) &
($mask as $unit_field_int_ty))
}
}
).unwrap()
@ -1147,12 +1147,18 @@ impl<'a> FieldCodegen<'a> for BitfieldUnit {
.build_ty(field_ty.clone());
fields.extend(Some(field));
let unit_field_int_ty = match self.layout().size {
let mut field_int_size = self.layout().size;
if !field_int_size.is_power_of_two() {
field_int_size = field_int_size.next_power_of_two();
}
let unit_field_int_ty = match field_int_size {
8 => quote_ty!(ctx.ext_cx(), u64),
4 => quote_ty!(ctx.ext_cx(), u32),
2 => quote_ty!(ctx.ext_cx(), u16),
1 => quote_ty!(ctx.ext_cx(), u8),
_ => {
size => {
debug_assert!(size > 8);
// Can't generate bitfield accessors for unit sizes larget than
// 64 bits at the moment.
struct_layout.saw_bitfield_unit(self.layout());
@ -1273,17 +1279,26 @@ impl<'a> FieldCodegen<'a> for Bitfield {
let bitfield_ty = bitfield_ty.to_rust_ty_or_opaque(ctx, bitfield_ty_item);
let offset = self.offset_into_unit();
let mask: usize = self.mask();
let mask = self.mask();
let impl_item = quote_item!(
ctx.ext_cx(),
impl XxxIgnored {
#[inline]
pub fn $getter_name(&self) -> $bitfield_ty {
let mask = $mask as $unit_field_int_ty;
let unit_field_val: $unit_field_int_ty = unsafe {
::$prefix::mem::transmute(self.$unit_field_ident)
let mut unit_field_val: $unit_field_int_ty = unsafe {
::$prefix::mem::uninitialized()
};
unsafe {
::$prefix::ptr::copy_nonoverlapping(
&self.$unit_field_ident as *const _ as *const u8,
&mut unit_field_val as *mut $unit_field_int_ty as *mut u8,
::$prefix::mem::size_of::<$unit_field_int_ty>(),
)
};
let mask = $mask as $unit_field_int_ty;
let val = (unit_field_val & mask) >> $offset;
unsafe {
::$prefix::mem::transmute(val as $bitfield_int_ty)
@ -1296,14 +1311,27 @@ impl<'a> FieldCodegen<'a> for Bitfield {
let val = val as $bitfield_int_ty as $unit_field_int_ty;
let mut unit_field_val: $unit_field_int_ty = unsafe {
::$prefix::mem::transmute(self.$unit_field_ident)
::$prefix::mem::uninitialized()
};
unsafe {
::$prefix::ptr::copy_nonoverlapping(
&self.$unit_field_ident as *const _ as *const u8,
&mut unit_field_val as *mut $unit_field_int_ty as *mut u8,
::$prefix::mem::size_of::<$unit_field_int_ty>(),
)
};
unit_field_val &= !mask;
unit_field_val |= (val << $offset) & mask;
self.$unit_field_ident = unsafe {
::$prefix::mem::transmute(unit_field_val)
};
unsafe {
::$prefix::ptr::copy_nonoverlapping(
&unit_field_val as *const _ as *const u8,
&mut self.$unit_field_ident as *mut _ as *mut u8,
::$prefix::mem::size_of::<$unit_field_int_ty>(),
);
}
}
}
).unwrap();
@ -2264,7 +2292,8 @@ impl CodeGenerator for Enum {
builder = builder.with_attr(derives);
}
fn add_constant<'a>(enum_: &Type,
fn add_constant<'a>(ctx: &BindgenContext,
enum_: &Type,
// Only to avoid recomputing every time.
enum_canonical_name: &str,
// May be the same as "variant" if it's because the
@ -2275,7 +2304,11 @@ impl CodeGenerator for Enum {
enum_rust_ty: P<ast::Ty>,
result: &mut CodegenResult<'a>) {
let constant_name = if enum_.name().is_some() {
format!("{}_{}", enum_canonical_name, variant_name)
if ctx.options().prepend_enum_name {
format!("{}_{}", enum_canonical_name, variant_name)
} else {
variant_name.into()
}
} else {
variant_name.into()
};
@ -2358,7 +2391,8 @@ impl CodeGenerator for Enum {
};
let existing_variant_name = entry.get();
add_constant(enum_ty,
add_constant(ctx,
enum_ty,
&name,
&*mangled_name,
existing_variant_name,
@ -2397,7 +2431,8 @@ impl CodeGenerator for Enum {
variant_name))
};
add_constant(enum_ty,
add_constant(ctx,
enum_ty,
&name,
&mangled_name,
&variant_name,
@ -2709,7 +2744,7 @@ impl TryToRustTy for Type {
let template_params = item.used_template_params(ctx)
.unwrap_or(vec![])
.into_iter()
.filter(|param| param.is_named(ctx, &()))
.filter(|param| param.is_template_param(ctx, &()))
.collect::<Vec<_>>();
let spelling = self.name().expect("Unnamed alias?");

18
third_party/rust/bindgen/src/ir/comp.rs поставляемый
Просмотреть файл

@ -293,18 +293,15 @@ impl Bitfield {
/// Get the mask value that when &'ed with this bitfield's allocation unit
/// produces this bitfield's value.
///
/// TODO(emilio): This should probably use the target's word size, and what
/// about bitfields that are bigger than that?
pub fn mask(&self) -> usize {
pub fn mask(&self) -> u64 {
use std::mem;
use std::usize;
use std::u64;
let unoffseted_mask =
if self.width() as usize == mem::size_of::<usize>() * 8 {
usize::MAX
if self.width() as u64 == mem::size_of::<u64>() as u64 * 8 {
u64::MAX
} else {
((1usize << self.width()) - 1usize)
((1u64 << self.width()) - 1u64)
};
unoffseted_mask << self.offset_into_unit()
@ -488,8 +485,9 @@ fn bitfields_to_allocation_units<E, I>(ctx: &BindgenContext,
where E: Extend<Field>
{
*bitfield_unit_count += 1;
let layout = Layout::new(bytes_from_bits_pow2(unit_size_in_bits),
bytes_from_bits_pow2(unit_align_in_bits));
let align = bytes_from_bits_pow2(unit_align_in_bits);
let size = align_to(unit_size_in_bits, align * 8) / 8;
let layout = Layout::new(size, align);
fields.extend(Some(Field::Bitfields(BitfieldUnit {
nth: *bitfield_unit_count,
layout: layout,

22
third_party/rust/bindgen/src/ir/context.rs поставляемый
Просмотреть файл

@ -139,9 +139,6 @@ pub struct BindgenContext<'ctx> {
/// The active replacements collected from replaces="xxx" annotations.
replacements: HashMap<Vec<String>, ItemId>,
/// The target string bindgen was able to deduce from the input.
effective_target: String,
collected_typerefs: bool,
/// Dummy structures for code generation.
@ -168,6 +165,9 @@ pub struct BindgenContext<'ctx> {
/// The set of `TypeKind::Comp` items found during parsing that need their
/// bitfield allocation units computed. Drained in `compute_bitfield_units`.
need_bitfield_allocation: Vec<ItemId>,
/// Whether we need the mangling hack which removes the prefixing underscore.
needs_mangling_hack: bool,
}
/// A traversal of whitelisted items.
@ -261,6 +261,16 @@ impl<'ctx> BindgenContext<'ctx> {
effective_target = Some(HOST_TARGET.to_owned());
}
// Mac os and Win32 need __ for mangled symbols but rust will automatically
// prepend the extra _.
//
// We need to make sure that we don't include __ because rust will turn into
// ___.
let effective_target = effective_target.unwrap();
let needs_mangling_hack =
effective_target.contains("darwin") ||
effective_target == "i686-pc-win32";
let root_module = Self::build_root_module(ItemId(0));
let mut me = BindgenContext {
items: Default::default(),
@ -273,7 +283,6 @@ impl<'ctx> BindgenContext<'ctx> {
currently_parsed_types: vec![],
parsed_macros: Default::default(),
replacements: Default::default(),
effective_target: effective_target.unwrap(),
collected_typerefs: false,
gen_ctx: None,
span: DUMMY_SP,
@ -283,6 +292,7 @@ impl<'ctx> BindgenContext<'ctx> {
generated_bindegen_complex: Cell::new(false),
used_template_parameters: None,
need_bitfield_allocation: Default::default(),
needs_mangling_hack: needs_mangling_hack,
};
me.add_item(root_module, None, None);
@ -795,8 +805,8 @@ impl<'ctx> BindgenContext<'ctx> {
}
/// Returns the target triple bindgen is running over.
pub fn target(&self) -> &str {
&self.effective_target
pub fn needs_mangling_hack(&self) -> bool {
self.needs_mangling_hack
}
/// Get the root module.

10
third_party/rust/bindgen/src/ir/function.rs поставляемый
Просмотреть файл

@ -128,16 +128,8 @@ fn get_abi(cc: CXCallingConv) -> Abi {
})
}
// Mac os and Win32 need __ for mangled symbols but rust will automatically
// prepend the extra _.
//
// We need to make sure that we don't include __ because rust will turn into
// ___.
fn mangling_hack_if_needed(ctx: &BindgenContext, symbol: &mut String) {
// NB: win64 also contains the substring "win32" in the target triple, so
// we need to actually check for i686...
if ctx.target().contains("darwin") ||
(ctx.target().contains("i686") && ctx.target().contains("windows")) {
if ctx.needs_mangling_hack() {
symbol.remove(0);
}
}

22
third_party/rust/bindgen/src/ir/item.rs поставляемый
Просмотреть файл

@ -8,7 +8,7 @@ use super::function::Function;
use super::item_kind::ItemKind;
use super::layout::Opaque;
use super::module::Module;
use super::template::{AsNamed, TemplateParameters};
use super::template::{AsTemplateParam, TemplateParameters};
use super::traversal::{EdgeKind, Trace, Tracer};
use super::ty::{Type, TypeKind};
use clang;
@ -131,28 +131,28 @@ impl<'a, 'b> Iterator for ItemAncestorsIter<'a, 'b>
}
}
impl AsNamed for ItemId {
impl AsTemplateParam for ItemId {
type Extra = ();
fn as_named(&self, ctx: &BindgenContext, _: &()) -> Option<ItemId> {
ctx.resolve_item(*self).as_named(ctx, &())
fn as_template_param(&self, ctx: &BindgenContext, _: &()) -> Option<ItemId> {
ctx.resolve_item(*self).as_template_param(ctx, &())
}
}
impl AsNamed for Item {
impl AsTemplateParam for Item {
type Extra = ();
fn as_named(&self, ctx: &BindgenContext, _: &()) -> Option<ItemId> {
self.kind.as_named(ctx, self)
fn as_template_param(&self, ctx: &BindgenContext, _: &()) -> Option<ItemId> {
self.kind.as_template_param(ctx, self)
}
}
impl AsNamed for ItemKind {
impl AsTemplateParam for ItemKind {
type Extra = Item;
fn as_named(&self, ctx: &BindgenContext, item: &Item) -> Option<ItemId> {
fn as_template_param(&self, ctx: &BindgenContext, item: &Item) -> Option<ItemId> {
match *self {
ItemKind::Type(ref ty) => ty.as_named(ctx, item),
ItemKind::Type(ref ty) => ty.as_template_param(ctx, item),
ItemKind::Module(..) |
ItemKind::Function(..) |
ItemKind::Var(..) => None,
@ -756,7 +756,7 @@ impl Item {
// Named template type arguments are never namespaced, and never
// mangled.
if target.is_named(ctx, &()) {
if target.is_template_param(ctx, &()) {
return base_name;
}

14
third_party/rust/bindgen/src/ir/template.rs поставляемый
Просмотреть файл

@ -176,19 +176,19 @@ pub trait TemplateParameters {
}
/// A trait for things which may or may not be a named template type parameter.
pub trait AsNamed {
pub trait AsTemplateParam {
/// Any extra information the implementor might need to make this decision.
type Extra;
/// Convert this thing to the item id of a named template type parameter.
fn as_named(&self,
ctx: &BindgenContext,
extra: &Self::Extra)
-> Option<ItemId>;
fn as_template_param(&self,
ctx: &BindgenContext,
extra: &Self::Extra)
-> Option<ItemId>;
/// Is this a named template type parameter?
fn is_named(&self, ctx: &BindgenContext, extra: &Self::Extra) -> bool {
self.as_named(ctx, extra).is_some()
fn is_template_param(&self, ctx: &BindgenContext, extra: &Self::Extra) -> bool {
self.as_template_param(ctx, extra).is_some()
}
}

14
third_party/rust/bindgen/src/ir/ty.rs поставляемый
Просмотреть файл

@ -10,7 +10,7 @@ use super::int::IntKind;
use super::item::Item;
use super::layout::{Layout, Opaque};
use super::objc::ObjCInterface;
use super::template::{AsNamed, TemplateInstantiation, TemplateParameters};
use super::template::{AsTemplateParam, TemplateInstantiation, TemplateParameters};
use super::traversal::{EdgeKind, Trace, Tracer};
use clang::{self, Cursor};
use parse::{ClangItemParser, ParseError, ParseResult};
@ -374,21 +374,21 @@ impl Type {
}
}
impl AsNamed for Type {
impl AsTemplateParam for Type {
type Extra = Item;
fn as_named(&self, ctx: &BindgenContext, item: &Item) -> Option<ItemId> {
self.kind.as_named(ctx, item)
fn as_template_param(&self, ctx: &BindgenContext, item: &Item) -> Option<ItemId> {
self.kind.as_template_param(ctx, item)
}
}
impl AsNamed for TypeKind {
impl AsTemplateParam for TypeKind {
type Extra = Item;
fn as_named(&self, ctx: &BindgenContext, item: &Item) -> Option<ItemId> {
fn as_template_param(&self, ctx: &BindgenContext, item: &Item) -> Option<ItemId> {
match *self {
TypeKind::Named => Some(item.id()),
TypeKind::ResolvedTypeRef(id) => id.as_named(ctx, &()),
TypeKind::ResolvedTypeRef(id) => id.as_template_param(ctx, &()),
_ => None,
}
}

28
third_party/rust/bindgen/src/ir/var.rs поставляемый
Просмотреть файл

@ -284,17 +284,35 @@ fn parse_macro(ctx: &BindgenContext,
-> Option<(Vec<u8>, cexpr::expr::EvalResult)> {
use cexpr::{expr, nom};
let cexpr_tokens = match unit.cexpr_tokens(cursor) {
let mut cexpr_tokens = match unit.cexpr_tokens(cursor) {
None => return None,
Some(tokens) => tokens,
};
let parser = expr::IdentifierParser::new(ctx.parsed_macros());
let result = parser.macro_definition(&cexpr_tokens);
match result {
nom::IResult::Done(_, (id, val)) => Some((id.into(), val)),
_ => None,
match parser.macro_definition(&cexpr_tokens) {
nom::IResult::Done(_, (id, val)) => {
return Some((id.into(), val));
}
_ => {}
}
// Try without the last token, to workaround a libclang bug in versions
// previous to 4.0.
//
// See:
// https://bugs.llvm.org//show_bug.cgi?id=9069
// https://reviews.llvm.org/D26446
if cexpr_tokens.pop().is_none() {
return None;
}
match parser.macro_definition(&cexpr_tokens) {
nom::IResult::Done(_, (id, val)) => {
Some((id.into(), val))
}
_ => None
}
}

8
third_party/rust/bindgen/src/lib.rs поставляемый
Просмотреть файл

@ -333,7 +333,7 @@ impl Builder {
}
if !self.options.unstable_rust {
output_vector.push("--no-unstable-rust".into());
output_vector.push("--unstable-rust".into());
}
self.options
@ -736,8 +736,8 @@ impl Builder {
}
/// Avoid generating any unstable Rust, such as Rust unions, in the generated bindings.
pub fn no_unstable_rust(mut self) -> Builder {
self.options.unstable_rust = false;
pub fn unstable_rust(mut self, doit: bool) -> Self {
self.options.unstable_rust = doit;
self
}
@ -959,7 +959,7 @@ impl Default for BindgenOptions {
derive_default: false,
enable_cxx_namespaces: false,
disable_name_namespacing: false,
unstable_rust: true,
unstable_rust: false,
use_core: false,
ctypes_prefix: None,
namespaced_constants: true,

10
third_party/rust/bindgen/src/options.rs поставляемый
Просмотреть файл

@ -135,9 +135,9 @@ pub fn builder_from_flags<I>
Arg::with_name("no-prepend-enum-name")
.long("no-prepend-enum-name")
.help("Do not prepend the enum name to bitfield or constant variants."),
Arg::with_name("no-unstable-rust")
.long("no-unstable-rust")
.help("Do not generate unstable Rust code.")
Arg::with_name("unstable-rust")
.long("unstable-rust")
.help("Generate unstable Rust code.")
.multiple(true), // FIXME: Pass legacy test suite
Arg::with_name("opaque-type")
.long("opaque-type")
@ -325,8 +325,8 @@ pub fn builder_from_flags<I>
builder = builder.ignore_methods();
}
if matches.is_present("no-unstable-rust") {
builder = builder.no_unstable_rust();
if matches.is_present("unstable-rust") {
builder = builder.unstable_rust(true);
}
if matches.is_present("no-convert-floats") {

6
toolkit/library/gtest/rust/Cargo.lock сгенерированный
Просмотреть файл

@ -89,7 +89,7 @@ dependencies = [
[[package]]
name = "bindgen"
version = "0.25.5"
version = "0.26.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -900,7 +900,7 @@ dependencies = [
"arraydeque 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"arrayvec 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bindgen 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)",
"bindgen 0.26.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1238,7 +1238,7 @@ dependencies = [
"checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159"
"checksum binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88ceb0d16c4fd0e42876e298d7d3ce3780dd9ebdcbe4199816a32c77e08597ff"
"checksum bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e103c8b299b28a9c6990458b7013dc4a8356a9b854c51b9883241f5866fac36e"
"checksum bindgen 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cc7973dbc2990511877ad9e5e50a312f02fbbc9b356c30bb102307424fa73630"
"checksum bindgen 0.26.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04488a91af8f15eec4d88eb59e2c4e982c03ff31582acf2f5623e2e6d8ae9e0b"
"checksum bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9bf6104718e80d7b26a68fdbacff3481cfc05df670821affc7e9cbc1884400c"
"checksum bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5b97c2c8e8bbb4251754f559df8af22fb264853c7d009084a576cdf12565089d"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"

6
toolkit/library/rust/Cargo.lock сгенерированный
Просмотреть файл

@ -87,7 +87,7 @@ dependencies = [
[[package]]
name = "bindgen"
version = "0.25.5"
version = "0.26.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aster 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -887,7 +887,7 @@ dependencies = [
"arraydeque 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"arrayvec 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bindgen 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)",
"bindgen 0.26.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -1225,7 +1225,7 @@ dependencies = [
"checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159"
"checksum binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88ceb0d16c4fd0e42876e298d7d3ce3780dd9ebdcbe4199816a32c77e08597ff"
"checksum bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e103c8b299b28a9c6990458b7013dc4a8356a9b854c51b9883241f5866fac36e"
"checksum bindgen 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cc7973dbc2990511877ad9e5e50a312f02fbbc9b356c30bb102307424fa73630"
"checksum bindgen 0.26.1 (registry+https://github.com/rust-lang/crates.io-index)" = "04488a91af8f15eec4d88eb59e2c4e982c03ff31582acf2f5623e2e6d8ae9e0b"
"checksum bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9bf6104718e80d7b26a68fdbacff3481cfc05df670821affc7e9cbc1884400c"
"checksum bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5b97c2c8e8bbb4251754f559df8af22fb264853c7d009084a576cdf12565089d"
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"