本文整理汇总了C++中kjs::JSObject::prototype方法的典型用法代码示例。如果您正苦于以下问题:C++ JSObject::prototype方法的具体用法?C++ JSObject::prototype怎么用?C++ JSObject::prototype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kjs::JSObject
的用法示例。
在下文中一共展示了JSObject::prototype方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exceptionToString
// from khtml/ecma/debugger/debugwindow.cpp
static QString exceptionToString(KJS::ExecState* exec, KJS::JSValue* exceptionObj)
{
QString exceptionMsg = valueToString(exceptionObj);
// Since we purposefully bypass toString, we need to figure out
// string serialization ourselves.
//### might be easier to export class info for ErrorInstance ---
KJS::JSObject* valueObj = exceptionObj->getObject();
KJS::JSValue* protoObj = valueObj ? valueObj->prototype() : 0;
bool exception = false;
bool syntaxError = false;
if (protoObj == exec->lexicalInterpreter()->builtinSyntaxErrorPrototype())
{
exception = true;
syntaxError = true;
}
if (protoObj == exec->lexicalInterpreter()->builtinErrorPrototype() ||
protoObj == exec->lexicalInterpreter()->builtinEvalErrorPrototype() ||
protoObj == exec->lexicalInterpreter()->builtinReferenceErrorPrototype() ||
protoObj == exec->lexicalInterpreter()->builtinRangeErrorPrototype() ||
protoObj == exec->lexicalInterpreter()->builtinTypeErrorPrototype() ||
protoObj == exec->lexicalInterpreter()->builtinURIErrorPrototype())
{
exception = true;
}
if (!exception)
return exceptionMsg;
// Clear exceptions temporarily so we can get/call a few things.
// We memorize the old exception first, of course. Note that
// This is not always the same as exceptionObj since we may be
// asked to translate a non-active exception
KJS::JSValue* oldExceptionObj = exec->exception();
exec->clearException();
// We want to serialize the syntax errors ourselves, to provide the line number.
// The URL is in "sourceURL" and the line is in "line"
// ### TODO: Perhaps we want to use 'sourceId' in case of eval contexts.
if (syntaxError)
{
KJS::JSValue* lineValue = valueObj->get(exec, "line");
KJS::JSValue* urlValue = valueObj->get(exec, "sourceURL");
int line = lineValue->toNumber(exec);
QString url = urlValue->toString(exec).qstring();
exceptionMsg = i18n("Parse error at %1 line %2",
url, line + 1);
}
else
{
// ### it's still not 100% safe to call toString here, even on
// native exception objects, since someone might have changed the toString property
// of the exception prototype, but I'll punt on this case for now.
exceptionMsg = exceptionObj->toString(exec).qstring();
}
exec->setException(oldExceptionObj);
return exceptionMsg;
}