本文整理汇总了C++中jsval::toBoolean方法的典型用法代码示例。如果您正苦于以下问题:C++ jsval::toBoolean方法的具体用法?C++ jsval::toBoolean怎么用?C++ jsval::toBoolean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsval
的用法示例。
在下文中一共展示了jsval::toBoolean方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Handle
NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult)
{
MOZ_ASSERT(NS_IsMainThread());
// The geolocation is enabled by default:
bool value = true;
if (aResult.isBoolean()) {
value = aResult.toBoolean();
}
MozSettingValue(value);
return NS_OK;
}
示例2: Handle
NS_DECL_ISUPPORTS
NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult, JSContext* aCx)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(gBluetoothService);
if (!aResult.isBoolean()) {
NS_WARNING("Setting for '" BLUETOOTH_ENABLED_SETTING "' is not a boolean!");
return NS_OK;
}
return aResult.toBoolean() ? gBluetoothService->Start() : NS_OK;
}
示例3: Handle
NS_DECL_ISUPPORTS
NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult)
{
MOZ_ASSERT(NS_IsMainThread());
if (!aResult.isBoolean()) {
NS_WARNING("Setting for '" BLUETOOTH_ENABLED_SETTING "' is not a boolean!");
return NS_OK;
}
// It is theoretically possible to shut down before the first settings check
// has completed (though extremely unlikely).
if (gBluetoothService) {
return gBluetoothService->HandleStartupSettingsCheck(aResult.toBoolean());
}
return NS_OK;
}
示例4: switch
bool
JavaScriptShared::toVariant(JSContext *cx, jsval from, JSVariant *to)
{
switch (JS_TypeOfValue(cx, from)) {
case JSTYPE_VOID:
*to = void_t();
return true;
case JSTYPE_NULL:
{
*to = uint64_t(0);
return true;
}
case JSTYPE_OBJECT:
case JSTYPE_FUNCTION:
{
JSObject *obj = from.toObjectOrNull();
if (!obj) {
JS_ASSERT(from == JSVAL_NULL);
*to = uint64_t(0);
return true;
}
if (xpc_JSObjectIsID(cx, obj)) {
JSIID iid;
const nsID *id = xpc_JSObjectToID(cx, obj);
ConvertID(*id, &iid);
*to = iid;
return true;
}
ObjectId id;
if (!makeId(cx, obj, &id))
return false;
*to = uint64_t(id);
return true;
}
case JSTYPE_STRING:
{
nsDependentJSString dep;
if (!dep.init(cx, from))
return false;
*to = dep;
return true;
}
case JSTYPE_NUMBER:
if (JSVAL_IS_INT(from))
*to = double(from.toInt32());
else
*to = from.toDouble();
return true;
case JSTYPE_BOOLEAN:
*to = from.toBoolean();
return true;
default:
MOZ_ASSERT(false);
return false;
}
}