Browse Source

- Add JavaScript ownership for QBigInt (declaration in constructors).

cl-refactor
yann300 10 years ago
committed by yann300
parent
commit
92bdd6fd2f
  1. 12
      mix/DebuggingStateWrapper.cpp
  2. 13
      mix/QBigInt.h

12
mix/DebuggingStateWrapper.cpp

@ -70,23 +70,17 @@ std::tuple<QList<QObject*>, QQMLMap*> DebuggingStateWrapper::getHumanReadableCod
QBigInt* DebuggingStateWrapper::gasCost()
{
QBigInt* re = new QBigInt(m_state.gasCost, this);
QQmlEngine::setObjectOwnership(re, QQmlEngine::JavaScriptOwnership);
return re;
return new QBigInt(m_state.gasCost);
}
QBigInt* DebuggingStateWrapper::gas()
{
QBigInt* r = new QBigInt(m_state.gas, this);
QQmlEngine::setObjectOwnership(r, QQmlEngine::JavaScriptOwnership);
return r;
return new QBigInt(m_state.gas);
}
QBigInt* DebuggingStateWrapper::newMemSize()
{
QBigInt* r = new QBigInt(m_state.newMemSize, this);
QQmlEngine::setObjectOwnership(r, QQmlEngine::JavaScriptOwnership);
return r;
return new QBigInt(m_state.newMemSize);
}
QStringList DebuggingStateWrapper::debugStack()

13
mix/QBigInt.h

@ -25,6 +25,7 @@
#include "boost/variant.hpp"
#include "boost/variant/multivisitors.hpp"
#include <QObject>
#include <QQmlEngine>
#include <libdevcore/CommonJS.h>
#include <libdevcore/Common.h>
@ -61,15 +62,19 @@ struct divide: public boost::static_visitor<BigIntVariant>
BigIntVariant operator()(T1 const& _value, T2 const& _otherValue) const { return _value / _otherValue; }
};
/*
* Represent big integer like big int and u256 in QML.
* The ownership is set by default to Javascript.
*/
class QBigInt: public QObject
{
Q_OBJECT
public:
QBigInt(QObject* _parent = 0): QObject(_parent), m_internalValue(dev::u256(0)) {}
QBigInt(dev::u256 const& _value, QObject* _parent = 0): QObject(_parent), m_internalValue(_value) {}
QBigInt(dev::bigint const& _value, QObject* _parent = 0): QObject(_parent), m_internalValue(_value) {}
QBigInt(BigIntVariant const& _value, QObject* _parent = 0): QObject(_parent), m_internalValue(_value){}
QBigInt(QObject* _parent = 0): QObject(_parent), m_internalValue(dev::u256(0)) { QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); }
QBigInt(dev::u256 const& _value, QObject* _parent = 0): QObject(_parent), m_internalValue(_value) { QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); }
QBigInt(dev::bigint const& _value, QObject* _parent = 0): QObject(_parent), m_internalValue(_value) { QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); }
QBigInt(BigIntVariant const& _value, QObject* _parent = 0): QObject(_parent), m_internalValue(_value){ QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership); }
~QBigInt() {}
/// @returns the current used big integer.

Loading…
Cancel
Save