From 598336e657cb4bf5ef5070dfa35b999b7dfd341b Mon Sep 17 00:00:00 2001 From: Alison Watson Date: Wed, 3 Jul 2019 22:50:28 -0400 Subject: [PATCH] add before header include option --- src/configuration.rs | 4 ++++ src/cpp.rs | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/configuration.rs b/src/configuration.rs index 1bd1c9f..c1289de 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -29,6 +29,8 @@ mod json { pub rust: Rust, #[serde(default = "false_bool")] pub overwrite_implementation: bool, + #[serde(rename = "beforeHeader", default)] + pub before_header: String, } #[derive(Deserialize)] @@ -83,6 +85,7 @@ pub struct Config { pub rust: Rust, pub rust_edition: RustEdition, pub overwrite_implementation: bool, + pub before_header: String, } impl ConfigPrivate for Config { @@ -492,6 +495,7 @@ fn post_process(config_file: &Path, json: json::Config) -> Result Result<()> { "/* generated by rust_qt_binding_generator */ #ifndef {0} #define {0} - -#include -#include ", guard )?; + if conf.before_header != "" { + writeln!(h, "#include \"{}\"", conf.before_header)?; + } + writeln!(h, " +#include +#include ")?; for name in conf.objects.keys() { writeln!(h, "class {};", name)?;