From 7ba03beb40a59246d4afeedb47a2fda45d861fb0 Mon Sep 17 00:00:00 2001 From: Mikhail Zolotukhin Date: Sat, 8 Jan 2022 22:23:50 +0300 Subject: [PATCH] feat(qmetaobject): add null and undefined functions to QJSValue --- qmetaobject/src/qtdeclarative.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/qmetaobject/src/qtdeclarative.rs b/qmetaobject/src/qtdeclarative.rs index 41520cb4..e4112302 100644 --- a/qmetaobject/src/qtdeclarative.rs +++ b/qmetaobject/src/qtdeclarative.rs @@ -506,11 +506,7 @@ pub fn qml_register_type( /// /// [qt]: https://doc.qt.io/qt-5/qqmlengine.html#qmlRegisterModule #[cfg(qt_5_9)] -pub fn qml_register_module( - uri: &CStr, - version_major: u32, - version_minor: u32, -) { +pub fn qml_register_module(uri: &CStr, version_major: u32, version_minor: u32) { let uri_ptr = uri.as_ptr(); cpp!(unsafe [ @@ -937,6 +933,18 @@ pub enum QJSValueSpecialValue { } impl QJSValue { + pub fn null() -> Self { + cpp!(unsafe [] -> QJSValue as "QJSValue" { + return QJSValue(QJSValue::SpecialValue::NullValue); + }) + } + + pub fn undefined() -> Self { + cpp!(unsafe [] -> QJSValue as "QJSValue" { + return QJSValue(QJSValue::SpecialValue::UndefinedValue); + }) + } + pub fn is_bool(&self) -> bool { cpp!(unsafe [self as "const QJSValue *"] -> bool as "bool" { return self->isBool();