本文整理汇总了C++中js::Handle::isInt32方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::isInt32方法的具体用法?C++ Handle::isInt32怎么用?C++ Handle::isInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类js::Handle
的用法示例。
在下文中一共展示了Handle::isInt32方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Handle
NS_IMETHOD Handle(const nsAString& aName, JS::Handle<JS::Value> aResult)
{
RefPtr<AudioManager> audioManager = AudioManager::GetInstance();
MOZ_ASSERT(audioManager);
for (uint32_t idx = 0; idx < MOZ_ARRAY_LENGTH(gVolumeData); ++idx) {
NS_ConvertASCIItoUTF16 volumeType(gVolumeData[idx].mChannelName);
if (StringBeginsWith(aName, volumeType)) {
uint32_t device = GetDeviceFromSettingName(aName);
MOZ_ASSERT(device != AUDIO_DEVICE_NONE);
if (aResult.isInt32()) {
int32_t stream = gVolumeData[idx].mStreamType;
uint32_t volIndex = aResult.toInt32();
nsresult rv = audioManager->ValidateVolumeIndex(stream, volIndex);
if (NS_WARN_IF(NS_FAILED(rv))) {
mPromiseHolder.Reject("Error : invalid volume index.", __func__);
return rv;
}
audioManager->SetStreamVolumeForDevice(stream, volIndex, device);
}
if (++mInitCounter == MOZ_ARRAY_LENGTH(kAudioDeviceInfos) * MOZ_ARRAY_LENGTH(gVolumeData)) {
mPromiseHolder.Resolve(true, __func__);
}
return NS_OK;
}
}
mPromiseHolder.Reject("Error : unexpected audio init event.", __func__);
return NS_OK;
}
示例2: MobileMessageCallback
NS_IMETHODIMP
MobileMessageManager::Delete(JS::Handle<JS::Value> aParam, JSContext* aCx,
nsIDOMDOMRequest** aRequest)
{
// We expect Int32, SmsMessage, MmsMessage, Int32[], SmsMessage[], MmsMessage[]
if (!aParam.isObject() && !aParam.isInt32()) {
return NS_ERROR_INVALID_ARG;
}
nsresult rv = NS_OK;
int32_t id, *idArray;
uint32_t size;
if (aParam.isInt32()) {
// Single Integer Message ID
id = aParam.toInt32();
size = 1;
idArray = &id;
} else if (!JS_IsArrayObject(aCx, &aParam.toObject())) {
// Single SmsMessage/MmsMessage object
rv = GetMessageId(aCx, aParam, &id);
NS_ENSURE_SUCCESS(rv, rv);
size = 1;
idArray = &id;
} else {
// Int32[], SmsMessage[], or MmsMessage[]
JS::Rooted<JSObject*> ids(aCx, &aParam.toObject());
JS_ALWAYS_TRUE(JS_GetArrayLength(aCx, ids, &size));
nsAutoArrayPtr<int32_t> idAutoArray(new int32_t[size]);
JS::Rooted<JS::Value> idJsValue(aCx);
for (uint32_t i = 0; i < size; i++) {
if (!JS_GetElement(aCx, ids, i, &idJsValue)) {
return NS_ERROR_INVALID_ARG;
}
if (idJsValue.isInt32()) {
idAutoArray[i] = idJsValue.toInt32();
} else if (idJsValue.isObject()) {
rv = GetMessageId(aCx, idJsValue, &id);
NS_ENSURE_SUCCESS(rv, rv);
idAutoArray[i] = id;
}
}
idArray = idAutoArray.forget();
}
nsCOMPtr<nsIMobileMessageDatabaseService> dbService =
do_GetService(MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(dbService, NS_ERROR_FAILURE);
nsRefPtr<DOMRequest> request = new DOMRequest(GetOwner());
nsCOMPtr<nsIMobileMessageCallback> msgCallback =
new MobileMessageCallback(request);
rv = dbService->DeleteMessage(idArray, size, msgCallback);
NS_ENSURE_SUCCESS(rv, rv);
request.forget(aRequest);
return NS_OK;
}