Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: Stop using bitflags to declare FFI definitions. #66

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [0.21.0] - 2017-10-10

### Fixed
* Fixed soundness of flags in Linux32.

## [0.20.1] - 2017-09-16

### Fixed
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name = "clang-sys"
authors = ["Kyle Mayes <kyle@mayeses.com>"]

version = "0.20.1"
version = "0.21.0"

readme = "README.md"
license = "Apache-2.0"
Expand Down Expand Up @@ -38,7 +38,6 @@ static = []

[dependencies]

bitflags = "0.9.1"
glob = "0.2.11"
libc = "0.2.14"
libloading = { version = "0.4.0", optional = true }
Expand Down
70 changes: 31 additions & 39 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
#![cfg_attr(feature="clippy", plugin(clippy))]
#![cfg_attr(feature="clippy", warn(clippy))]

#[macro_use]
extern crate bitflags;

extern crate glob;
extern crate libc;
#[cfg(feature="runtime")]
Expand Down Expand Up @@ -66,6 +63,13 @@ macro_rules! cenum {
}) => (
pub type $name = c_int;

$($(#[$vmeta])* pub const $variant: $name = $value;)+
);
($(#[$meta:meta])* enum $name:ident {
$($(#[$vmeta:meta])* const $variant:ident = $value:expr); +;
}) => (
pub type $name = c_int;

$($(#[$vmeta])* pub const $variant: $name = $value;)+
);
}
Expand Down Expand Up @@ -890,18 +894,16 @@ cenum! {
// Flags
//================================================

bitflags! {
#[repr(C)]
pub struct CXCodeComplete_Flags: c_uint {
cenum! {
enum CXCodeComplete_Flags {
const CXCodeComplete_IncludeMacros = 1;
const CXCodeComplete_IncludeCodePatterns = 2;
const CXCodeComplete_IncludeBriefComments = 4;
}
}

bitflags! {
#[repr(C)]
pub struct CXCompletionContext: c_uint {
cenum! {
enum CXCompletionContext {
const CXCompletionContext_Unexposed = 0;
const CXCompletionContext_AnyType = 1;
const CXCompletionContext_AnyValue = 2;
Expand Down Expand Up @@ -929,9 +931,8 @@ bitflags! {
}
}

bitflags! {
#[repr(C)]
pub struct CXDiagnosticDisplayOptions: c_uint {
cenum! {
enum CXDiagnosticDisplayOptions {
const CXDiagnostic_DisplaySourceLocation = 1;
const CXDiagnostic_DisplayColumn = 2;
const CXDiagnostic_DisplaySourceRanges = 4;
Expand All @@ -941,26 +942,23 @@ bitflags! {
}
}

bitflags! {
#[repr(C)]
pub struct CXGlobalOptFlags: c_uint {
cenum! {
enum CXGlobalOptFlags {
const CXGlobalOpt_None = 0;
const CXGlobalOpt_ThreadBackgroundPriorityForIndexing = 1;
const CXGlobalOpt_ThreadBackgroundPriorityForEditing = 2;
const CXGlobalOpt_ThreadBackgroundPriorityForAll = 3;
}
}

bitflags! {
#[repr(C)]
pub struct CXIdxDeclInfoFlags: c_uint {
cenum! {
enum CXIdxDeclInfoFlags {
const CXIdxDeclFlag_Skipped = 1;
}
}

bitflags! {
#[repr(C)]
pub struct CXIndexOptFlags: c_uint {
cenum! {
enum CXIndexOptFlags {
const CXIndexOptNone = 0;
const CXIndexOptSuppressRedundantRefs = 1;
const CXIndexOptIndexFunctionLocalSymbols = 2;
Expand All @@ -970,18 +968,16 @@ bitflags! {
}
}

bitflags! {
#[repr(C)]
pub struct CXNameRefFlags: c_uint {
cenum! {
enum CXNameRefFlags {
const CXNameRange_WantQualifier = 1;
const CXNameRange_WantTemplateArgs = 2;
const CXNameRange_WantSinglePiece = 4;
}
}

bitflags! {
#[repr(C)]
pub struct CXObjCDeclQualifierKind: c_uint {
cenum! {
enum CXObjCDeclQualifierKind {
const CXObjCDeclQualifier_None = 0;
const CXObjCDeclQualifier_In = 1;
const CXObjCDeclQualifier_Inout = 2;
Expand All @@ -992,9 +988,8 @@ bitflags! {
}
}

bitflags! {
#[repr(C)]
pub struct CXObjCPropertyAttrKind: c_uint {
cenum! {
enum CXObjCPropertyAttrKind {
const CXObjCPropertyAttr_noattr = 0;
const CXObjCPropertyAttr_readonly = 1;
const CXObjCPropertyAttr_getter = 2;
Expand All @@ -1013,23 +1008,20 @@ bitflags! {
}
}

bitflags! {
#[repr(C)]
pub struct CXReparse_Flags: c_uint {
cenum! {
enum CXReparse_Flags {
const CXReparse_None = 0;
}
}

bitflags! {
#[repr(C)]
pub struct CXSaveTranslationUnit_Flags: c_uint {
cenum! {
enum CXSaveTranslationUnit_Flags {
const CXSaveTranslationUnit_None = 0;
}
}

bitflags! {
#[repr(C)]
pub struct CXTranslationUnit_Flags: c_uint {
cenum! {
enum CXTranslationUnit_Flags {
const CXTranslationUnit_None = 0;
const CXTranslationUnit_DetailedPreprocessingRecord = 1;
const CXTranslationUnit_Incomplete = 2;
Expand Down
2 changes: 1 addition & 1 deletion tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn parse() {
0,
ptr::null_mut(),
0,
CXTranslationUnit_Flags::empty(),
0,
);
assert!(!tu.is_null());
}
Expand Down