qjsvalue.sip 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // qjsvalue.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtQml Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. typedef QList<QJSValue> QJSValueList;
  22. class QJSValue /TypeHintIn="Union[QJSValue, QJSValue.SpecialValue, bool, int, float, QString]"/
  23. {
  24. %TypeHeaderCode
  25. #include <qjsvalue.h>
  26. %End
  27. %ConvertToTypeCode
  28. if (!sipIsErr)
  29. return qpyqml_canConvertTo_QJSValue(sipPy);
  30. return qpyqml_convertTo_QJSValue(sipPy, sipTransferObj, sipCppPtr, sipIsErr);
  31. %End
  32. public:
  33. enum SpecialValue
  34. {
  35. NullValue,
  36. UndefinedValue,
  37. };
  38. %If (Qt_6_1_0 -)
  39. enum ObjectConversionBehavior
  40. {
  41. ConvertJSObjects,
  42. RetainJSObjects,
  43. };
  44. %End
  45. QJSValue(QJSValue::SpecialValue value /Constrained/ = QJSValue::UndefinedValue);
  46. QJSValue(const QJSValue &other);
  47. ~QJSValue();
  48. bool isBool() const;
  49. bool isNumber() const;
  50. bool isNull() const;
  51. bool isString() const;
  52. bool isUndefined() const;
  53. bool isVariant() const;
  54. bool isQObject() const;
  55. bool isObject() const;
  56. bool isDate() const;
  57. bool isRegExp() const;
  58. bool isArray() const;
  59. bool isError() const;
  60. %If (Qt_6_2_0 -)
  61. bool isUrl() const;
  62. %End
  63. QString toString() const;
  64. double toNumber() const;
  65. qint32 toInt() const;
  66. quint32 toUInt() const;
  67. bool toBool() const;
  68. QVariant toVariant() const;
  69. %If (Qt_6_1_0 -)
  70. QVariant toVariant(QJSValue::ObjectConversionBehavior behavior) const;
  71. %End
  72. %If (Qt_6_1_0 -)
  73. QJSPrimitiveValue toPrimitive() const;
  74. %End
  75. QObject *toQObject() const;
  76. QDateTime toDateTime() const;
  77. bool equals(const QJSValue &other) const;
  78. bool strictlyEquals(const QJSValue &other) const;
  79. QJSValue prototype() const;
  80. void setPrototype(const QJSValue &prototype);
  81. QJSValue property(const QString &name) const;
  82. void setProperty(const QString &name, const QJSValue &value);
  83. bool hasProperty(const QString &name) const;
  84. bool hasOwnProperty(const QString &name) const;
  85. QJSValue property(quint32 arrayIndex) const;
  86. void setProperty(quint32 arrayIndex, const QJSValue &value);
  87. bool deleteProperty(const QString &name);
  88. bool isCallable() const;
  89. QJSValue call(const QJSValueList &args = QJSValueList()) const;
  90. QJSValue callWithInstance(const QJSValue &instance, const QJSValueList &args = QJSValueList()) const;
  91. QJSValue callAsConstructor(const QJSValueList &args = QJSValueList()) const;
  92. enum ErrorType
  93. {
  94. GenericError,
  95. EvalError,
  96. RangeError,
  97. ReferenceError,
  98. SyntaxError,
  99. TypeError,
  100. URIError,
  101. };
  102. QJSValue::ErrorType errorType() const;
  103. };
  104. QDataStream &operator<<(QDataStream &, const QJSValue &) /ReleaseGIL/;
  105. QDataStream &operator>>(QDataStream &, QJSValue & /Constrained/) /ReleaseGIL/;