diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-07-01 05:40:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-01 05:40:00 -0700 |
commit | 7726d5a18a0d7a6ffb3db4350905ce75e1b1e6d3 (patch) | |
tree | 30a89ab198260aa137cee1365c65aa57c62b5072 | |
parent | 08e7fe4f83ab9f3b03f789cfacb6eccb60cdd182 (diff) | |
parent | 33270a98e0e06d7b86d04472a303a6f2f21cf83f (diff) |
Auto merge of #2 - servo:class-consts, r=Ms2ger
parser: Disable conditionally class constants
Part of the fix for #1
-rw-r--r-- | src/bin/bindgen.rs | 4 | ||||
-rw-r--r-- | src/lib.rs | 9 | ||||
-rw-r--r-- | src/parser.rs | 5 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/bin/bindgen.rs b/src/bin/bindgen.rs index 6cd0059b..fd0a7ffe 100644 --- a/src/bin/bindgen.rs +++ b/src/bin/bindgen.rs @@ -120,6 +120,10 @@ fn parse_args(args: &[String]) -> ParseResult { options.gen_bitfield_methods = false; ix += 1; } + "-no-class-constants" => { + options.class_constants = false; + ix += 1; + } "-dtor-attr" => { if ix + 1 >= args_len { return ParseResult::ParseErr("Missing dtor attr".to_string()); @@ -122,6 +122,11 @@ impl<'a> Builder<'a> { self } + pub fn disable_class_constants(&mut self) -> &mut Self { + self.options.class_constants = false; + self + } + pub fn generate(&self) -> Result<Bindings, ()> { Bindings::generate(&self.options, self.logger, None) } @@ -152,6 +157,8 @@ pub struct BindgenOptions { pub enable_cxx_namespaces: bool, pub rename_types: bool, pub derive_debug: bool, + /// Wether to generate C++ class constants. + pub class_constants: bool, pub override_enum_ty: String, pub raw_lines: Vec<String>, /// Attributes for a type with destructor @@ -176,6 +183,7 @@ impl Default for BindgenOptions { derive_debug: true, enable_cxx_namespaces: false, override_enum_ty: "".to_string(), + class_constants: true, raw_lines: vec![], dtor_attrs: vec![], clang_args: vec![], @@ -295,6 +303,7 @@ fn parse_headers(options: &BindgenOptions, logger: &Logger) -> Result<ModuleMap, builtins: options.builtins, match_pat: options.match_pat.clone(), emit_ast: options.emit_ast, + class_constants: options.class_constants, ignore_functions: options.ignore_functions, fail_on_unknown_type: options.fail_on_unknown_type, enable_cxx_namespaces: options.enable_cxx_namespaces, diff --git a/src/parser.rs b/src/parser.rs index 6b942b2a..18a87a58 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -25,6 +25,7 @@ pub struct ClangParserOptions { pub fail_on_unknown_type: bool, pub ignore_functions: bool, pub enable_cxx_namespaces: bool, + pub class_constants: bool, pub override_enum_ty: Option<il::IKind>, pub clang_args: Vec<String>, pub opaque_types: Vec<String>, @@ -990,6 +991,10 @@ fn visit_composite(cursor: &Cursor, parent: &Cursor, ci.has_non_type_template_params = true; } CXCursor_VarDecl => { + if !ctx.options.class_constants { + return CXChildVisit_Continue; + } + let linkage = cursor.linkage(); if linkage != CXLinkage_External && linkage != CXLinkage_UniqueExternal { return CXChildVisit_Continue; |