本文整理汇总了C++中js::MutableHandleValue::setUndefined方法的典型用法代码示例。如果您正苦于以下问题:C++ MutableHandleValue::setUndefined方法的具体用法?C++ MutableHandleValue::setUndefined怎么用?C++ MutableHandleValue::setUndefined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类js::MutableHandleValue
的用法示例。
在下文中一共展示了MutableHandleValue::setUndefined方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ar
bool rs::jsapi::Object::Set(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool strict, JS::MutableHandleValue vp) {
JSAutoRequest ar(cx);
auto state = Object::GetState(cx, obj);
if (state != nullptr && state->setter != nullptr) {
Value value(cx, vp);
char nameBuffer[256];
auto name = JSID_TO_STRING(id);
auto nameLength = JS_EncodeStringToBuffer(cx, name, nameBuffer, sizeof(nameBuffer) - 1);
try {
if (nameLength < sizeof(nameBuffer)) {
nameBuffer[nameLength] = '\0';
state->setter(nameBuffer, value);
} else {
std::vector<char> nameVector(nameLength + 1);
nameLength = JS_EncodeStringToBuffer(cx, name, &nameVector[0], nameVector.size() - 1);
nameVector[nameLength] = '\0';
state->setter(&nameVector[0], value);
}
return true;
} catch (const std::exception& ex) {
JS_ReportError(cx, ex.what());
return false;
}
} else {
// TODO: what will this do to the JS?
vp.setUndefined();
return true;
}
}
示例2: rq
template<> void ScriptInterface::ToJSVal<const char*>(JSContext* cx, JS::MutableHandleValue ret, const char* const& val)
{
JSAutoRequest rq(cx);
JS::RootedString str(cx, JS_NewStringCopyZ(cx, val));
if (str)
ret.setString(str);
else
ret.setUndefined();
}
示例3: GuiPoll
void CNetClient::GuiPoll(JS::MutableHandleValue ret)
{
if (m_GuiMessageQueue.empty())
{
ret.setUndefined();
return;
}
ret.set(m_GuiMessageQueue.front());
m_GuiMessageQueue.pop_front();
}
示例4: rq
// TODO: This is copy-pasted from scriptinterface/ScriptConversions.cpp (#define VECTOR stuff), would be nice to remove the duplication
template<> void ScriptInterface::ToJSVal<std::vector<CFixedVector2D> >(JSContext* cx, JS::MutableHandleValue ret, const std::vector<CFixedVector2D>& val)
{
JSAutoRequest rq(cx);
JS::RootedObject obj(cx, JS_NewArrayObject(cx, 0));
if (!obj)
{
ret.setUndefined();
return;
}
for (size_t i = 0; i < val.size(); ++i)
{
JS::RootedValue el(cx);
ScriptInterface::ToJSVal<CFixedVector2D>(cx, &el, val[i]);
JS_SetElement(cx, obj, i, el);
}
ret.setObject(*obj);
}
示例5: rq
template<> void ScriptInterface::ToJSVal<CFixedVector2D>(JSContext* cx, JS::MutableHandleValue ret, const CFixedVector2D& val)
{
JSAutoRequest rq(cx);
// apply the Vector2D prototype to the return value
ScriptInterface::CxPrivate* pCxPrivate = ScriptInterface::GetScriptInterfaceAndCBData(cx);
JS::RootedObject proto(cx, &pCxPrivate->pScriptInterface->GetCachedValue(ScriptInterface::CACHE_VECTOR2DPROTO).toObject());
JS::RootedObject obj(cx, JS_NewObject(cx, nullptr, proto, JS::NullPtr()));
if (!obj)
{
ret.setUndefined();
return;
}
JS::RootedValue x(cx);
JS::RootedValue y(cx);
ToJSVal(cx, &x, val.X);
ToJSVal(cx, &y, val.Y);
JS_SetProperty(cx, obj, "x", x);
JS_SetProperty(cx, obj, "y", y);
ret.setObject(*obj);
}
示例6:
NS_IMETHODIMP
nsScriptErrorBase::GetStack(JS::MutableHandleValue aStack) {
aStack.setUndefined();
return NS_OK;
}