本文整理汇总了C++中jsc::JSValue::toObject方法的典型用法代码示例。如果您正苦于以下问题:C++ JSValue::toObject方法的具体用法?C++ JSValue::toObject怎么用?C++ JSValue::toObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsc::JSValue
的用法示例。
在下文中一共展示了JSValue::toObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
PassRefPtr<ScriptCallStack> createScriptCallStackFromException(JSC::ExecState* exec, JSC::JSValue& exception, size_t maxStackSize)
{
Vector<ScriptCallFrame> frames;
RefCountedArray<StackFrame> stackTrace = exec->vm().exceptionStack();
for (size_t i = 0; i < stackTrace.size() && i < maxStackSize; i++) {
if (!stackTrace[i].callee && frames.size())
break;
String functionName = stackTrace[i].friendlyFunctionName(exec);
unsigned line;
unsigned column;
stackTrace[i].computeLineAndColumn(line, column);
frames.append(ScriptCallFrame(functionName, stackTrace[i].sourceURL, line, column));
}
// FIXME: <http://webkit.org/b/115087> Web Inspector: WebCore::reportException should not evaluate JavaScript handling exceptions
// Fallback to getting at least the line and sourceURL from the exception if it has values and the exceptionStack doesn't.
if (frames.size() > 0) {
const ScriptCallFrame& firstCallFrame = frames.first();
JSObject* exceptionObject = exception.toObject(exec);
if (exception.isObject() && firstCallFrame.sourceURL().isEmpty()) {
JSValue lineValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "line"));
int lineNumber = lineValue && lineValue.isNumber() ? int(lineValue.toNumber(exec)) : 0;
JSValue sourceURLValue = exceptionObject->getDirect(exec->vm(), Identifier(exec, "sourceURL"));
String exceptionSourceURL = sourceURLValue && sourceURLValue.isString() ? sourceURLValue.toString(exec)->value(exec) : ASCIILiteral("undefined");
frames[0] = ScriptCallFrame(firstCallFrame.functionName(), exceptionSourceURL, lineNumber, 0);
}
}
return ScriptCallStack::create(frames);
}
示例2: asFilenames
void DragData::asFilenames(Vector<String>& result) const
{
bool success;
JSC::JSValue data = m_platformDragData->getData(ClipboardApolloHelper::FILE_LIST_TYPE, success);
JSC::ExecState *exec = m_platformDragData->execState();
if (success && data.isObject()) {
JSC::JSObject* filenameArray = data.toObject(exec);
uint32_t length = filenameArray->get(exec, JSC::Identifier(exec, "length")).toUInt32(exec);
for (uint32_t i=0; i<length; i++) {
JSC::JSValue fileValue = filenameArray->get(exec, i);
if (fileValue.isObject()) {
JSC::JSObject* file = fileValue.toObject(exec);
JSC::JSValue pathValue = file->get(exec, JSC::Identifier(exec, "nativePath"));
if (pathValue.isString()) {
String path = ustringToString(pathValue.toString(exec));
result.append(path);
}
}
}
}
if (exec->hadException())
exec->clearException();
}