add before header include option
parent
fddfbd59c5
commit
598336e657
|
@ -29,6 +29,8 @@ mod json {
|
||||||
pub rust: Rust,
|
pub rust: Rust,
|
||||||
#[serde(default = "false_bool")]
|
#[serde(default = "false_bool")]
|
||||||
pub overwrite_implementation: bool,
|
pub overwrite_implementation: bool,
|
||||||
|
#[serde(rename = "beforeHeader", default)]
|
||||||
|
pub before_header: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
|
@ -83,6 +85,7 @@ pub struct Config {
|
||||||
pub rust: Rust,
|
pub rust: Rust,
|
||||||
pub rust_edition: RustEdition,
|
pub rust_edition: RustEdition,
|
||||||
pub overwrite_implementation: bool,
|
pub overwrite_implementation: bool,
|
||||||
|
pub before_header: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfigPrivate for Config {
|
impl ConfigPrivate for Config {
|
||||||
|
@ -492,6 +495,7 @@ fn post_process(config_file: &Path, json: json::Config) -> Result<Config, Box<Er
|
||||||
rust: json.rust,
|
rust: json.rust,
|
||||||
rust_edition,
|
rust_edition,
|
||||||
overwrite_implementation: json.overwrite_implementation,
|
overwrite_implementation: json.overwrite_implementation,
|
||||||
|
before_header: json.before_header,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1400,12 +1400,15 @@ pub fn write_header(conf: &Config) -> Result<()> {
|
||||||
"/* generated by rust_qt_binding_generator */
|
"/* generated by rust_qt_binding_generator */
|
||||||
#ifndef {0}
|
#ifndef {0}
|
||||||
#define {0}
|
#define {0}
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
|
||||||
#include <QtCore/QAbstractItemModel>
|
|
||||||
",
|
",
|
||||||
guard
|
guard
|
||||||
)?;
|
)?;
|
||||||
|
if conf.before_header != "" {
|
||||||
|
writeln!(h, "#include \"{}\"", conf.before_header)?;
|
||||||
|
}
|
||||||
|
writeln!(h, "
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QAbstractItemModel>")?;
|
||||||
|
|
||||||
for name in conf.objects.keys() {
|
for name in conf.objects.keys() {
|
||||||
writeln!(h, "class {};", name)?;
|
writeln!(h, "class {};", name)?;
|
||||||
|
|
Loading…
Reference in New Issue