当前位置: 首页>>代码示例>>C++>>正文


C++ ExecutionContext::catchException方法代码示例

本文整理汇总了C++中ExecutionContext::catchException方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecutionContext::catchException方法的具体用法?C++ ExecutionContext::catchException怎么用?C++ ExecutionContext::catchException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExecutionContext的用法示例。


在下文中一共展示了ExecutionContext::catchException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: toQStringNoThrow

QString Value::toQStringNoThrow() const
{
    switch (type()) {
    case Value::Empty_Type:
        Q_ASSERT(!"empty Value encountered");
    case Value::Undefined_Type:
        return QStringLiteral("undefined");
    case Value::Null_Type:
        return QStringLiteral("null");
    case Value::Boolean_Type:
        if (booleanValue())
            return QStringLiteral("true");
        else
            return QStringLiteral("false");
    case Value::Managed_Type:
        if (isString())
            return stringValue()->toQString();
        {
            ExecutionContext *ctx = objectValue()->internalClass()->engine->currentContext();
            Scope scope(ctx);
            ScopedValue ex(scope);
            bool caughtException = false;
            ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ValueRef::fromRawValue(this), STRING_HINT));
            if (scope.hasException()) {
                ex = ctx->catchException();
                caughtException = true;
            } else if (prim->isPrimitive()) {
                    return prim->toQStringNoThrow();
            }
            // Can't nest try/catch due to CXX ABI limitations for foreign exception nesting.
            if (caughtException) {
                ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ex, STRING_HINT));
                if (scope.hasException()) {
                    ex = ctx->catchException();
                } else if (prim->isPrimitive()) {
                    return prim->toQStringNoThrow();
                }
            }
            return QString();
        }
    case Value::Integer_Type: {
        QString str;
        RuntimeHelpers::numberToString(&str, (double)int_32, 10);
        return str;
    }
    default: { // double
        QString str;
        RuntimeHelpers::numberToString(&str, doubleValue(), 10);
        return str;
    }
    } // switch
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:52,代码来源:qv4value.cpp

示例2: deleteProperty

/*!
  Attempts to delete this object's property of the given \a name.
  Returns true if the property was deleted, otherwise returns false.

  The behavior of this function is consistent with the JavaScript
  delete operator. In particular:

  \list
  \li Non-configurable properties cannot be deleted.
  \li This function will return true even if this object doesn't
     have a property of the given \a name (i.e., non-existent
     properties are "trivially deletable").
  \li If this object doesn't have an own property of the given
     \a name, but an object in the prototype() chain does, the
     prototype object's property is not deleted, and this function
     returns true.
  \endlist

  \sa setProperty(), hasOwnProperty()
*/
bool QJSValue::deleteProperty(const QString &name)
{
    ExecutionEngine *engine = d->engine;
    ExecutionContext *ctx = engine->currentContext();
    Scope scope(engine);
    ScopedObject o(scope, d->value.asObject());
    if (!o)
        return false;

    ScopedString s(scope, engine->newString(name));
    bool b = o->deleteProperty(s);
    if (scope.hasException())
        ctx->catchException();
    return b;
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:35,代码来源:qjsvalue.cpp


注:本文中的ExecutionContext::catchException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。