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


C++ JSObject::getPropertyNames方法代码示例

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


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

示例1: convertToVariant

QMap<QString, QVariant> KJSEmbed::convertArrayToMap(KJS::ExecState *exec, KJS::JSValue *value)
{
    QMap<QString, QVariant> returnMap;
    KJS::JSObject *obj = value->toObject(exec);
    KJS::PropertyNameArray lst;
    obj->getPropertyNames(exec, lst);
    KJS::PropertyNameArrayIterator idx = lst.begin();
    for (; idx != lst.end(); idx++) {
        KJS::Identifier id = *idx;
        KJS::JSValue *val  = obj->get(exec, id);
        returnMap[toQString(id)] = convertToVariant(exec, val);
    }
    return returnMap;
}
开发者ID:KDE,项目名称:kjsembed,代码行数:14,代码来源:variant_binding.cpp

示例2: index

QModelIndex KJSObjectModel::index(int row, int column, const QModelIndex &parent ) const
{
    KJS::JSObject *parentInstance = 0;
    Node *childItem = 0;
    KJS::ExecState *exec = m_js->globalExec();

    if (!parent.isValid())
    {
        if (m_root)
            parentInstance = m_root;
        else
            return QModelIndex();
    }
    else
        parentInstance = static_cast<Node*>(parent.internalPointer())->instance;
    int idx = 0;
    KJS::PropertyNameArray props;
    parentInstance->getPropertyNames(exec, props);
    for( KJS::PropertyNameArrayIterator ref = props.begin(); ref != props.end(); ref++)
    {
        if( idx == row)
        {
                childItem = new Node;
                childItem->name = ref->ascii(); //### M.O.: this is wrong, can be unicode.
                childItem->instance = parentInstance->get( exec,
                        childItem->name.constData() )->toObject(exec);
                childItem->parent = static_cast<Node*>(parent.internalPointer());
                break;
        }
        ++idx;
    }
    if (childItem)
        return createIndex(row, column, childItem);

    return QModelIndex();
}
开发者ID:vasi,项目名称:kdelibs,代码行数:36,代码来源:kjs_object_model.cpp


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