Skip to content

Commit 7ba03be

Browse files
author
Mikhail Zolotukhin
committed
feat(qmetaobject): add null and undefined functions to QJSValue
1 parent f1dd1d4 commit 7ba03be

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

qmetaobject/src/qtdeclarative.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,11 +506,7 @@ pub fn qml_register_type<T: QObject + Default + Sized>(
506506
///
507507
/// [qt]: https://doc.qt.io/qt-5/qqmlengine.html#qmlRegisterModule
508508
#[cfg(qt_5_9)]
509-
pub fn qml_register_module(
510-
uri: &CStr,
511-
version_major: u32,
512-
version_minor: u32,
513-
) {
509+
pub fn qml_register_module(uri: &CStr, version_major: u32, version_minor: u32) {
514510
let uri_ptr = uri.as_ptr();
515511

516512
cpp!(unsafe [
@@ -937,6 +933,18 @@ pub enum QJSValueSpecialValue {
937933
}
938934

939935
impl QJSValue {
936+
pub fn null() -> Self {
937+
cpp!(unsafe [] -> QJSValue as "QJSValue" {
938+
return QJSValue(QJSValue::SpecialValue::NullValue);
939+
})
940+
}
941+
942+
pub fn undefined() -> Self {
943+
cpp!(unsafe [] -> QJSValue as "QJSValue" {
944+
return QJSValue(QJSValue::SpecialValue::UndefinedValue);
945+
})
946+
}
947+
940948
pub fn is_bool(&self) -> bool {
941949
cpp!(unsafe [self as "const QJSValue *"] -> bool as "bool" {
942950
return self->isBool();

0 commit comments

Comments
 (0)