本文整理汇总了C++中JSGlobalObject::get方法的典型用法代码示例。如果您正苦于以下问题:C++ JSGlobalObject::get方法的具体用法?C++ JSGlobalObject::get怎么用?C++ JSGlobalObject::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSGlobalObject
的用法示例。
在下文中一共展示了JSGlobalObject::get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}