-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
In the generated cpp_closures.cpp, every chunk of code copied verbatim from cpp!([]{}) content is preceded by #line pragma and a line with an inconsistently large amount of spaces. Which probably indicated there is some minor bug in parser.
For example, these fragments of Rust:
fn get_object_description() -> &'static QObjectDescriptor
where
Self: Sized,
{
unsafe {
&*cpp!([]-> *const QObjectDescriptor as "RustQObjectDescriptor const*" {
return RustQObjectDescriptor::instance<RustObject<QObject>>();
})
}
} pub unsafe fn as_qvariant(&self) -> QVariant {
let self_ = self.get_cpp_object();
cpp!([self_ as "QObject*"] -> QVariant as "QVariant" {
return QVariant::fromValue(self_);
})
} pub fn destroyed_signal() -> Signal<fn()> {
unsafe {
Signal::new(cpp!([] -> SignalInner as "SignalInner" {
return &QObject::destroyed;
}))
}
} pub fn set_object_name(&self, name: QString) {
let self_ = self.get_cpp_object();
unsafe {
cpp!([self_ as "QObject*", name as "QString"] {
if (self_) self_->setObjectName(std::move(name));
})
}
}produce this C++ output:
Macro code responsible for this is probably somewhere around here:
Lines 43 to 52 in b826bc5
| // Like the write! macro, but add the #line directive (pointing to this file). | |
| // Note: the string literal must be on on the same line of the macro | |
| macro_rules! write_add_line { | |
| ($o:expr, $($e:tt)*) => { | |
| (|| { | |
| writeln!($o, "#line {} \"{}\"", line!(), file!().replace('\\', "\\\\"))?; | |
| write!($o, $($e)*) | |
| })() | |
| }; | |
| } |
Metadata
Metadata
Assignees
Labels
No labels
