本文整理汇总了C++中kjs::Value::toObject方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::toObject方法的具体用法?C++ Value::toObject怎么用?C++ Value::toObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kjs::Value
的用法示例。
在下文中一共展示了Value::toObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getObj
static KJS::Object getObj(KJS::Interpreter *js, KJS::Value mightBeArray, int id) {
KJS::ExecState *exec=js->globalExec();
KJS::Object constrs=mightBeArray.toObject(exec);
KJS::Value constr;
if (!exec->hadException()) {
if (QString(constrs.classInfo()->className)=="Array") {
kdDebug()<<"config page constructor array detected"<<endl;
constr=constrs.get(exec,id);
} else constr=mightBeArray;
}
return constr.toObject(js->globalExec());
}
示例2: constructorList
KJS::List KJSEmbedPart::constructorList() const
{
KJS::List items;
KJS::Object obj = js->globalObject();
KJS::ExecState *exec = js->globalExec();
KJS::ReferenceList l = obj.propList( exec );
KJS::ReferenceListIterator propIt = l.begin();
while ( propIt != l.end() ) {
KJS::Identifier name = propIt->getPropertyName( exec );
if ( obj.hasProperty( exec, name ) ) {
KJS::Value v = obj.get( exec, name );
KJS::Object vobj = v.toObject( exec );
if ( vobj.implementsConstruct() )
items.append( KJS::String( name.ustring() ) );
}
propIt++;
}
return items;
}
示例3: scopeWalker
static KJS::Object scopeWalker( KJS::ExecState *exec, const KJS::Object &root, const QString &objectString )
{
KJS::Object returnObject = root;
QStringList objects = QStringList::split(".", objectString);
for( uint idx = 0; idx < objects.count(); ++idx)
{
KJS::Identifier id = KJS::Identifier( KJS::UString( objects[idx] ));
KJS::Value newObject = returnObject.get(exec, id );
if( newObject.isValid() )
returnObject = newObject.toObject(exec);
}
return returnObject;
}
示例4: setD
void KstBindCubicBezier::setD(KJS::ExecState *exec, const KJS::Value& value) {
KstBindPoint *imp = 0L;
if (value.type() != KJS::ObjectType || !(imp = dynamic_cast<KstBindPoint*>(value.toObject(exec).imp()))) {
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
exec->setException(eobj);
return;
}
KstViewBezierPtr d = makeBezier(_d);
if (d) {
KstWriteLocker wl(d);
d->setPointD(QPoint(int(imp->_x), int(imp->_y))); // FIXME: Point is the wrong
// type to use here. It's
// a double, for one...
KstApp::inst()->paintAll(P_PAINT);
}
}
示例5: convertValueToNPVariant
// Variant value must be released with NPReleaseVariantValue()
void convertValueToNPVariant (KJS::ExecState *exec, const KJS::Value &value, NPVariant *result)
{
Type type = value.type();
if (type == StringType) {
UString ustring = value.toString(exec);
CString cstring = ustring.UTF8String();
NPString string = { (const NPUTF8 *)cstring.c_str(), cstring.size() };
NPN_InitializeVariantWithStringCopy (result, &string );
}
else if (type == NumberType) {
NPN_InitializeVariantWithDouble (result, value.toNumber(exec));
}
else if (type == BooleanType) {
NPN_InitializeVariantWithBool (result, value.toBoolean(exec));
}
else if (type == UnspecifiedType) {
NPN_InitializeVariantAsUndefined(result);
}
else if (type == NullType) {
NPN_InitializeVariantAsNull(result);
}
else if (type == ObjectType) {
KJS::ObjectImp *objectImp = static_cast<KJS::ObjectImp*>(value.imp());
if (objectImp->classInfo() == &KJS::RuntimeObjectImp::info) {
KJS::RuntimeObjectImp *imp = static_cast<KJS::RuntimeObjectImp *>(value.imp());
CInstance *instance = static_cast<CInstance*>(imp->getInternalInstance());
NPN_InitializeVariantWithObject (result, instance->getObject());
}
else {
KJS::Interpreter *originInterpreter = exec->interpreter();
const Bindings::RootObject *originExecutionContext = rootForInterpreter(originInterpreter);
KJS::Interpreter *interpreter = 0;
if (originInterpreter->isGlobalObject(value)) {
interpreter = originInterpreter->interpreterForGlobalObject (value.imp());
}
if (!interpreter)
interpreter = originInterpreter;
const Bindings::RootObject *executionContext = rootForInterpreter(interpreter);
if (!executionContext) {
Bindings::RootObject *newExecutionContext = new KJS::Bindings::RootObject(0);
newExecutionContext->setInterpreter (interpreter);
executionContext = newExecutionContext;
}
NPObject *obj = (NPObject *)exec->interpreter()->createLanguageInstanceForValue (exec, Instance::CLanguage, value.toObject(exec), originExecutionContext, executionContext);
NPN_InitializeVariantWithObject (result, obj);
_NPN_ReleaseObject (obj);
}
}
else
NPN_InitializeVariantAsUndefined(result);
}