本文整理汇总了C++中js::MutableHandleValue::toObjectOrNull方法的典型用法代码示例。如果您正苦于以下问题:C++ MutableHandleValue::toObjectOrNull方法的具体用法?C++ MutableHandleValue::toObjectOrNull怎么用?C++ MutableHandleValue::toObjectOrNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类js::MutableHandleValue
的用法示例。
在下文中一共展示了MutableHandleValue::toObjectOrNull方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _MozJSCreateFunction
void MozJSImplScope::_MozJSCreateFunction(const char* raw,
ScriptingFunction functionNumber,
JS::MutableHandleValue fun) {
std::string code = str::stream() << "_funcs" << functionNumber << " = "
<< parseJSFunctionOrExpression(_context, StringData(raw));
JS::CompileOptions co(_context);
setCompileOptions(&co);
_checkErrorState(JS::Evaluate(_context, _global, co, code.c_str(), code.length(), fun));
uassert(10232,
"not a function",
fun.isObject() && JS_ObjectIsFunction(_context, fun.toObjectOrNull()));
}
示例2: _MozJSCreateFunction
// TODO: This function identification code is broken. Fix it up to be more robust
//
// See: SERVER-16703 for more info
void MozJSImplScope::_MozJSCreateFunction(const char* raw,
ScriptingFunction functionNumber,
JS::MutableHandleValue fun) {
std::string code = jsSkipWhiteSpace(raw);
if (!hasFunctionIdentifier(code)) {
if (code.find('\n') == std::string::npos && !hasJSReturn(code) &&
(code.find(';') == std::string::npos || code.find(';') == code.size() - 1)) {
code = "return " + code;
}
code = "function(){ " + code + "}";
}
code = str::stream() << "_funcs" << functionNumber << " = " << code;
JS::CompileOptions co(_context);
setCompileOptions(&co);
_checkErrorState(JS::Evaluate(_context, _global, co, code.c_str(), code.length(), fun));
uassert(10232,
"not a function",
fun.isObject() && JS_ObjectIsFunction(_context, fun.toObjectOrNull()));
}
示例3: make
void NumberDecimalInfo::make(JSContext* cx, JS::MutableHandleValue thisv, Decimal128 decimal) {
auto scope = getScope(cx);
scope->getProto<NumberDecimalInfo>().newObject(thisv);
JS_SetPrivate(thisv.toObjectOrNull(), scope->trackedNew<Decimal128>(decimal));
}