本文整理汇总了C++中JSValue::toThisObject方法的典型用法代码示例。如果您正苦于以下问题:C++ JSValue::toThisObject方法的具体用法?C++ JSValue::toThisObject怎么用?C++ JSValue::toThisObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSValue
的用法示例。
在下文中一共展示了JSValue::toThisObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: evaluate
JSValue evaluate(ExecState* exec, const SourceCode& source, JSValue thisValue, JSValue* returnedException)
{
JSLockHolder lock(exec);
RELEASE_ASSERT(exec->vm().identifierTable == wtfThreadData().currentIdentifierTable());
RELEASE_ASSERT(!exec->vm().isCollectorBusy());
CodeProfiling profile(source);
ProgramExecutable* program = ProgramExecutable::create(exec, source);
if (!program) {
if (returnedException)
*returnedException = exec->vm().exception;
exec->vm().exception = JSValue();
return jsUndefined();
}
if (!thisValue || thisValue.isUndefinedOrNull())
thisValue = exec->dynamicGlobalObject();
JSObject* thisObj = thisValue.toThisObject(exec);
JSValue result = exec->interpreter()->execute(program, exec, thisObj);
if (exec->hadException()) {
if (returnedException)
*returnedException = exec->exception();
exec->clearException();
return jsUndefined();
}
RELEASE_ASSERT(result);
return result;
}
示例2: objectProtoFuncDefineSetter
JSValue QT_FASTCALL objectProtoFuncDefineSetter(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
CallData callData;
if (args.at(1).getCallData(callData) == CallTypeNone)
return throwError(exec, SyntaxError, "invalid setter usage");
thisValue.toThisObject(exec)->defineSetter(exec, Identifier(exec, args.at(0).toString(exec)), asObject(args.at(1)));
return jsUndefined();
}
示例3: objectProtoFuncDefineSetter
EncodedJSValue JSC_HOST_CALL objectProtoFuncDefineSetter(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
CallData callData;
if (getCallData(exec->argument(1), callData) == CallTypeNone)
return throwVMError(exec, createSyntaxError(exec, "invalid setter usage"));
thisValue.toThisObject(exec)->defineSetter(exec, Identifier(exec, exec->argument(0).toString(exec)), asObject(exec->argument(1)));
return JSValue::encode(jsUndefined());
}
示例4: objectProtoFuncIsPrototypeOf
JSValue QT_FASTCALL objectProtoFuncIsPrototypeOf(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
JSObject* thisObj = thisValue.toThisObject(exec);
if (!args.at(0).isObject())
return jsBoolean(false);
JSValue v = asObject(args.at(0))->prototype();
while (true) {
if (!v.isObject())
return jsBoolean(false);
if (v == thisObj)
return jsBoolean(true);
v = asObject(v)->prototype();
}
}
示例5: errorProtoFuncToString
JSValue JSC_HOST_CALL errorProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
{
JSObject* thisObj = thisValue.toThisObject(exec);
JSValue name = thisObj->get(exec, exec->propertyNames().name);
JSValue message = thisObj->get(exec, exec->propertyNames().message);
// Mozilla-compatible format.
if (!name.isUndefined()) {
if (!message.isUndefined())
return jsMakeNontrivialString(exec, name.toString(exec), ": ", message.toString(exec));
return jsNontrivialString(exec, name.toString(exec));
}
if (!message.isUndefined())
return jsMakeNontrivialString(exec, "Error: ", message.toString(exec));
return jsNontrivialString(exec, "Error");
}
示例6: objectProtoFuncIsPrototypeOf
EncodedJSValue JSC_HOST_CALL objectProtoFuncIsPrototypeOf(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
JSObject* thisObj = thisValue.toThisObject(exec);
if (!exec->argument(0).isObject())
return JSValue::encode(jsBoolean(false));
JSValue v = asObject(exec->argument(0))->prototype();
while (true) {
if (!v.isObject())
return JSValue::encode(jsBoolean(false));
if (v == thisObj)
return JSValue::encode(jsBoolean(true));
v = asObject(v)->prototype();
}
}
示例7: dateProtoFuncToJSON
JSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
{
JSObject* object = thisValue.toThisObject(exec);
if (exec->hadException())
return jsNull();
JSValue toISOValue = object->get(exec, exec->globalData().propertyNames->toISOString);
if (exec->hadException())
return jsNull();
CallData callData;
CallType callType = toISOValue.getCallData(callData);
if (callType == CallTypeNone)
return throwError(exec, TypeError, "toISOString is not a function");
JSValue result = call(exec, asObject(toISOValue), callType, callData, object, exec->emptyList());
if (exec->hadException())
return jsNull();
if (result.isObject())
return throwError(exec, TypeError, "toISOString did not return a primitive value");
return result;
}
示例8: call
JSValue JSCallbackFunction::call(ExecState* exec, JSObject* functionObject, JSValue thisValue, const ArgList& args)
{
JSContextRef execRef = toRef(exec);
JSObjectRef functionRef = toRef(functionObject);
JSObjectRef thisObjRef = toRef(thisValue.toThisObject(exec));
int argumentCount = static_cast<int>(args.size());
Vector<JSValueRef, 16> arguments(argumentCount);
for (int i = 0; i < argumentCount; i++)
arguments[i] = toRef(exec, args.at(i));
JSValueRef exception = 0;
JSValueRef result;
{
APICallbackShim callbackShim(exec);
result = static_cast<JSCallbackFunction*>(functionObject)->m_callback(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception);
}
if (exception)
exec->setException(toJS(exec, exception));
return toJS(exec, result);
}
示例9: dateProtoFuncToJSON
EncodedJSValue JSC_HOST_CALL dateProtoFuncToJSON(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
JSObject* object = thisValue.toThisObject(exec);
if (exec->hadException())
return JSValue::encode(jsNull());
JSValue toISOValue = object->get(exec, exec->globalData().propertyNames->toISOString);
if (exec->hadException())
return JSValue::encode(jsNull());
CallData callData;
CallType callType = getCallData(toISOValue, callData);
if (callType == CallTypeNone)
return throwVMError(exec, createTypeError(exec, "toISOString is not a function"));
JSValue result = call(exec, asObject(toISOValue), callType, callData, object, exec->emptyList());
if (exec->hadException())
return JSValue::encode(jsNull());
if (result.isObject())
return throwVMError(exec, createTypeError(exec, "toISOString did not return a primitive value"));
return JSValue::encode(result);
}
示例10: objectProtoFuncToString
EncodedJSValue JSC_HOST_CALL objectProtoFuncToString(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
return JSValue::encode(jsMakeNontrivialString(exec, "[object ", thisValue.toThisObject(exec)->className(), "]"));
}
示例11: addParentForConsoleStart
void ProfileGenerator::addParentForConsoleStart(ExecState* exec)
{
int lineNumber;
intptr_t sourceID;
UString sourceURL;
JSValue function;
exec->interpreter()->retrieveLastCaller(exec, lineNumber, sourceID, sourceURL, function);
m_currentNode = ProfileNode::create(exec, Profiler::createCallIdentifier(exec, function ? function.toThisObject(exec) : 0, sourceURL, lineNumber), m_head.get(), m_head.get());
m_head->insertNode(m_currentNode.get());
}
示例12: objectProtoFuncLookupSetter
JSValue QT_FASTCALL objectProtoFuncLookupSetter(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)
{
return thisValue.toThisObject(exec)->lookupSetter(exec, Identifier(exec, args.at(0).toString(exec)));
}
示例13: call
JSValue JSFunction::call(ExecState* exec, JSValue thisValue, const ArgList& args)
{
ASSERT(!isHostFunction());
return exec->interpreter()->execute(jsExecutable(), exec, this, thisValue.toThisObject(exec), args, scopeChain().node(), exec->exceptionSlot());
}
示例14: objectProtoFuncToString
JSValue QT_FASTCALL objectProtoFuncToString(ExecState* exec, JSObject*, JSValue thisValue, const ArgList&)
{
return jsNontrivialString(exec, makeString("[object ", thisValue.toThisObject(exec)->className(), "]"));
}
示例15: objectProtoFuncHasOwnProperty
EncodedJSValue JSC_HOST_CALL objectProtoFuncHasOwnProperty(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
return JSValue::encode(jsBoolean(thisValue.toThisObject(exec)->hasOwnProperty(exec, Identifier(exec, exec->argument(0).toString(exec)))));
}