Commit 2f17db73 authored by Ryan Hunt's avatar Ryan Hunt
Browse files

Allow specifying most config options on Builder

parent 3e3fd63b
......@@ -5,7 +5,7 @@
use std::path;
use bindgen::cargo::Cargo;
use bindgen::config::Config;
use bindgen::config::{Braces, Config, Language};
use bindgen::library::Library;
use bindgen::bindings::Bindings;
use bindgen::parser::{self, Parse};
......@@ -31,16 +31,115 @@ impl Builder {
}
}
#[allow(unused)]
pub fn with_header<S: AsRef<str>>(mut self, header: S) -> Builder {
self.config.header = Some(String::from(header.as_ref()));
self
}
#[allow(unused)]
pub fn with_trailer<S: AsRef<str>>(mut self, trailer: S) -> Builder {
self.config.trailer = Some(String::from(trailer.as_ref()));
self
}
#[allow(unused)]
pub fn with_include_guard<S: AsRef<str>>(mut self, include_guard: S) -> Builder {
self.config.include_guard = Some(String::from(include_guard.as_ref()));
self
}
#[allow(unused)]
pub fn with_autogen_warning<S: AsRef<str>>(mut self, autogen_warning: S) -> Builder {
self.config.autogen_warning = Some(String::from(autogen_warning.as_ref()));
self
}
#[allow(unused)]
pub fn with_include_version(mut self, include_version: bool) -> Builder {
self.config.include_version = include_version;
self
}
#[allow(unused)]
pub fn with_namespaces<S: AsRef<str>>(mut self, namespaces: &[S]) -> Builder {
self.config.namespaces = Some(namespaces.iter().map(|x| String::from(x.as_ref())).collect());
self
}
#[allow(unused)]
pub fn with_braces(mut self, braces: Braces) -> Builder {
self.config.braces = braces;
self
}
#[allow(unused)]
pub fn with_line_length(mut self, line_length: usize) -> Builder {
self.config.line_length = line_length;
self
}
#[allow(unused)]
pub fn with_tab_width(mut self, tab_width: usize) -> Builder {
self.config.tab_width = tab_width;
self
}
#[allow(unused)]
pub fn with_language(mut self, language: Language) -> Builder {
self.config.language = language;
self
}
#[allow(unused)]
pub fn with_parse_deps(mut self, parse_deps: bool) -> Builder {
self.config.parse.parse_deps = parse_deps;
self
}
#[allow(unused)]
pub fn with_parse_include<S: AsRef<str>>(mut self, include: &[S]) -> Builder {
self.config.parse.include = Some(include.iter().map(|x| String::from(x.as_ref())).collect());
self
}
#[allow(unused)]
pub fn with_parse_exclude<S: AsRef<str>>(mut self, exclude: &[S]) -> Builder {
self.config.parse.exclude = exclude.iter().map(|x| String::from(x.as_ref())).collect();
self
}
#[allow(unused)]
pub fn with_parse_expand<S: AsRef<str>>(mut self, expand: &[S]) -> Builder {
self.config.parse.expand = expand.iter().map(|x| String::from(x.as_ref())).collect();
self
}
#[allow(unused)]
pub fn with_generic_template_specialization(mut self, generic_template_specialization: bool) -> Builder {
self.config.structure.generic_template_specialization = generic_template_specialization;
self
}
#[allow(unused)]
pub fn with_documentation(mut self, documentation: bool) -> Builder {
self.config.documentation = documentation;
self
}
#[allow(unused)]
pub fn with_config(mut self, config: Config) -> Builder {
self.config = config;
self
}
#[allow(unused)]
pub fn with_std_types(mut self) -> Builder {
self.std_types = true;
self
}
#[allow(unused)]
pub fn with_src(mut self, src: &path::Path) -> Builder {
self.srcs.push(src.to_owned());
self
......
Supports Markdown
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