Skip to content

Commit f5a303b

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

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

qmetaobject/src/qtdeclarative.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,18 @@ pub enum QJSValueSpecialValue {
937937
}
938938

939939
impl QJSValue {
940+
pub fn null() -> Self {
941+
cpp!(unsafe [] -> QJSValue as "QJSValue" {
942+
return QJSValue(QJSValue::SpecialValue::NullValue);
943+
})
944+
}
945+
946+
pub fn undefined() -> Self {
947+
cpp!(unsafe [] -> QJSValue as "QJSValue" {
948+
return QJSValue(QJSValue::SpecialValue::UndefinedValue);
949+
})
950+
}
951+
940952
pub fn is_bool(&self) -> bool {
941953
cpp!(unsafe [self as "const QJSValue *"] -> bool as "bool" {
942954
return self->isBool();
@@ -1008,6 +1020,12 @@ impl QJSValue {
10081020
}
10091021
}
10101022

1023+
impl Default for QJSValue {
1024+
fn default() -> Self {
1025+
QJSValue::undefined()
1026+
}
1027+
}
1028+
10111029
impl From<QString> for QJSValue {
10121030
fn from(a: QString) -> QJSValue {
10131031
cpp!(unsafe [a as "QString"] -> QJSValue as "QJSValue" {

0 commit comments

Comments
 (0)