本文整理汇总了C++中ExecState::setException方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecState::setException方法的具体用法?C++ ExecState::setException怎么用?C++ ExecState::setException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecState
的用法示例。
在下文中一共展示了ExecState::setException方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _NPN_SetException
void _NPN_SetException (NPObject *o, NPString *message)
{
if (o->_class == NPScriptObjectClass) {
JavaScriptObject *obj = (JavaScriptObject *)o;
ExecState *exec = obj->executionContext->interpreter()->globalExec();
Interpreter::lock();
char *msg = (char *)malloc (message->UTF8Length + 1);
strncpy (msg, message->UTF8Characters, message->UTF8Length);
msg[message->UTF8Length] = 0;
Object err = Error::create(exec, GeneralError, msg);
free (msg);
exec->setException (err);
Interpreter::unlock();
}
}
示例2: valueByEvaluatingJavaScriptFromString
JSValue* WebScriptCallFrame::valueByEvaluatingJavaScriptFromString(String script)
{
#if 0
ExecState* state = m_state;
JSGlobalObject* globObj = state->dynamicGlobalObject();
// find "eval"
JSObject* eval = 0;
if (state->scopeNode()) { // "eval" won't work without context (i.e. at global scope)
JSValue* v = globObj->get(state, "eval");
if (v->isObject() && static_cast<JSObject*>(v)->implementsCall())
eval = static_cast<JSObject*>(v);
else
// no "eval" - fallback operates on global exec state
state = globObj->globalExec();
}
JSValue* savedException = state->exception();
state->clearException();
UString code(script.utf8().data());
// evaluate
JSValue* scriptExecutionResult;
if (eval) {
List args;
args.append(jsString(code));
scriptExecutionResult = eval->call(state, 0, args);
} else
// no "eval", or no context (i.e. global scope) - use global fallback
scriptExecutionResult = Interpreter::evaluate(state, UString(), 0, code.data(), code.size(), globObj).value();
if (state->hadException())
scriptExecutionResult = state->exception(); // (may be redundant depending on which eval path was used)
state->setException(savedException);
return scriptExecutionResult;
#else
return jsNull();
#endif
}