Skip to content

Commit

Permalink
feat(qmetaobject): add null and undefined functions to QJSValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Zolotukhin committed Jan 8, 2022
1 parent f1dd1d4 commit 7ba03be
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions qmetaobject/src/qtdeclarative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,7 @@ pub fn qml_register_type<T: QObject + Default + Sized>(
///
/// [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 [
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7ba03be

Please sign in to comment.