typegen: add QSDOC_TYPE_OVERRIDE
This commit is contained in:
parent
a8672e4eee
commit
a53a8f1cb4
|
@ -196,6 +196,13 @@ impl CppParser {
|
||||||
let mut signals = Vec::new();
|
let mut signals = Vec::new();
|
||||||
let mut enums = Vec::new();
|
let mut enums = Vec::new();
|
||||||
|
|
||||||
|
struct Carryover<'a> {
|
||||||
|
type_override: Option<&'a str>,
|
||||||
|
comment: Option<&'a str>,
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut carryover = Option::<Carryover<'a>>::None;
|
||||||
|
|
||||||
(|| {
|
(|| {
|
||||||
for macro_ in self.macro_regex.captures_iter(body) {
|
for macro_ in self.macro_regex.captures_iter(body) {
|
||||||
let macro_ = macro_?;
|
let macro_ = macro_?;
|
||||||
|
@ -204,10 +211,12 @@ impl CppParser {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
let comment = macro_.name("comment").map(|m| m.as_str());
|
let comment = macro_.name("comment").map(|m| m.as_str()).or(carryover.as_ref().map(|c| c.comment).flatten());
|
||||||
let type_ = macro_.name("type").unwrap().as_str();
|
let type_ = macro_.name("type").unwrap().as_str();
|
||||||
let args = macro_.name("args").map(|m| m.as_str());
|
let args = macro_.name("args").map(|m| m.as_str());
|
||||||
|
|
||||||
|
let this_carryover = carryover.take();
|
||||||
|
|
||||||
(|| {
|
(|| {
|
||||||
match type_ {
|
match type_ {
|
||||||
"QSDOC_BASECLASS" => {
|
"QSDOC_BASECLASS" => {
|
||||||
|
@ -230,6 +239,14 @@ impl CppParser {
|
||||||
"QML_SINGLETON" => singleton = true,
|
"QML_SINGLETON" => singleton = true,
|
||||||
"QML_UNCREATABLE" => uncreatable = true,
|
"QML_UNCREATABLE" => uncreatable = true,
|
||||||
"QSDOC_CREATABLE" => force_creatable = true,
|
"QSDOC_CREATABLE" => force_creatable = true,
|
||||||
|
"QSDOC_TYPE_OVERRIDE" => {
|
||||||
|
let type_override = args.ok_or_else(|| anyhow!("expected param for QSDOC_GENERIC"))?;
|
||||||
|
|
||||||
|
carryover = Some(Carryover {
|
||||||
|
type_override: Some(type_override),
|
||||||
|
comment,
|
||||||
|
});
|
||||||
|
}
|
||||||
"Q_PROPERTY" | "QSDOC_PROPERTY_OVERRIDE" => {
|
"Q_PROPERTY" | "QSDOC_PROPERTY_OVERRIDE" => {
|
||||||
let prop =
|
let prop =
|
||||||
self.property_regex
|
self.property_regex
|
||||||
|
@ -248,7 +265,7 @@ impl CppParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
properties.push(Property {
|
properties.push(Property {
|
||||||
type_: Cow::Borrowed(prop.name("type").unwrap().as_str()),
|
type_: Cow::Borrowed(this_carryover.as_ref().map(|c| c.type_override).flatten().unwrap_or_else(|| prop.name("type").unwrap().as_str())),
|
||||||
name: prop.name("name").unwrap().as_str(),
|
name: prop.name("name").unwrap().as_str(),
|
||||||
comment: comment.map(|v| Comment::new(v, ctx.module)),
|
comment: comment.map(|v| Comment::new(v, ctx.module)),
|
||||||
readable: read || member,
|
readable: read || member,
|
||||||
|
|
Loading…
Reference in a new issue