本文整理汇总了C++中MOZ_ARRAY_LENGTH函数的典型用法代码示例。如果您正苦于以下问题:C++ MOZ_ARRAY_LENGTH函数的具体用法?C++ MOZ_ARRAY_LENGTH怎么用?C++ MOZ_ARRAY_LENGTH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MOZ_ARRAY_LENGTH函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Convert
nsresult
Convert(const nsAString& aIn, BluetoothPinCode& aOut)
{
if (NS_WARN_IF(aIn.Length() > MOZ_ARRAY_LENGTH(aOut.mPinCode))) {
return NS_ERROR_ILLEGAL_VALUE;
}
NS_ConvertUTF16toUTF8 pinCodeUTF8(aIn);
const char* str = pinCodeUTF8.get();
nsAString::size_type i;
// Fill pin into aOut
for (i = 0; i < aIn.Length(); ++i, ++str) {
aOut.mPinCode[i] = static_cast<uint8_t>(*str);
}
// Clear remaining bytes in aOut
size_t ntrailing = (MOZ_ARRAY_LENGTH(aOut.mPinCode) - aIn.Length()) *
sizeof(aOut.mPinCode[0]);
memset(aOut.mPinCode + aIn.Length(), 0, ntrailing);
aOut.mLength = aIn.Length();
return NS_OK;
}
开发者ID:stormandsun,项目名称:firefox,代码行数:26,代码来源:BluetoothDaemonHelpers.cpp
示例2: DEF_GONK_RECORDER_PROFILE
namespace mozilla {
struct ProfileConfig {
const char* name;
int quality;
};
#define DEF_GONK_RECORDER_PROFILE(e, n) { n, e },
static const ProfileConfig ProfileList[] = {
#include "GonkRecorderProfiles.def"
};
static const size_t ProfileListSize = MOZ_ARRAY_LENGTH(ProfileList);
struct ProfileConfigDetect {
const char* name;
uint32_t width;
uint32_t height;
};
#define DEF_GONK_RECORDER_PROFILE_DETECT(n, w, h) { n, w, h },
static const ProfileConfigDetect ProfileListDetect[] = {
#include "GonkRecorderProfiles.def"
};
static const size_t ProfileListDetectSize = MOZ_ARRAY_LENGTH(ProfileListDetect);
};
开发者ID:AOSC-Dev,项目名称:Pale-Moon,代码行数:28,代码来源:GonkRecorderProfiles.cpp
示例3: MOZ_ARRAY_LENGTH
/* static */ bool
MP4Decoder::CanCreateAACDecoder()
{
#ifdef XP_WIN
static bool haveCachedResult = false;
static bool result = false;
if (haveCachedResult) {
return result;
}
AudioInfo config;
config.mMimeType = "audio/mp4a-latm";
config.mRate = 22050;
config.mChannels = 2;
config.mBitDepth = 16;
config.mProfile = 2;
config.mExtendedProfile = 2;
config.mCodecSpecificConfig->AppendElements(sTestAACConfig,
MOZ_ARRAY_LENGTH(sTestAACConfig));
config.mExtraData->AppendElements(sTestAACExtraData,
MOZ_ARRAY_LENGTH(sTestAACExtraData));
nsRefPtr<MediaDataDecoder> decoder(CreateTestAACDecoder(config));
if (decoder) {
result = true;
}
haveCachedResult = true;
return result;
#else
return IsEnabled();
#endif
}
开发者ID:Jinwoo-Song,项目名称:gecko-dev,代码行数:30,代码来源:MP4Decoder.cpp
示例4: main
int
main()
{
print_array("gLonghandProperties",
gLonghandProperties,
MOZ_ARRAY_LENGTH(gLonghandProperties),
gLonghandPropertiesWithDOMProp,
MOZ_ARRAY_LENGTH(gLonghandPropertiesWithDOMProp));
print_array("gShorthandProperties",
gShorthandProperties,
MOZ_ARRAY_LENGTH(gShorthandProperties),
gShorthandPropertiesWithDOMProp,
MOZ_ARRAY_LENGTH(gShorthandPropertiesWithDOMProp));
return 0;
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:15,代码来源:ListCSSProperties.cpp
示例5: nsVariant
nsresult
UploadStumbleRunnable::Upload()
{
nsresult rv;
RefPtr<nsVariant> variant = new nsVariant();
rv = variant->SetAsISupports(mUploadInputStream);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIXMLHttpRequest> xhr = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> systemPrincipal;
rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
NS_ENSURE_SUCCESS(rv, rv);
rv = xhr->Init(systemPrincipal, nullptr, nullptr, nullptr);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIURLFormatter> formatter =
do_CreateInstance("@mozilla.org/toolkit/URLFormatterService;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsString url;
rv = formatter->FormatURLPref(NS_LITERAL_STRING("geo.stumbler.url"), url);
NS_ENSURE_SUCCESS(rv, rv);
rv = xhr->Open(NS_LITERAL_CSTRING("POST"), NS_ConvertUTF16toUTF8(url), false, EmptyString(), EmptyString());
NS_ENSURE_SUCCESS(rv, rv);
xhr->SetRequestHeader(NS_LITERAL_CSTRING("Content-Type"), NS_LITERAL_CSTRING("gzip"));
xhr->SetMozBackgroundRequest(true);
// 60s timeout
xhr->SetTimeout(60 * 1000);
nsCOMPtr<EventTarget> target(do_QueryInterface(xhr));
RefPtr<nsIDOMEventListener> listener = new UploadEventListener(xhr);
const char* const sEventStrings[] = {
// nsIXMLHttpRequestEventTarget event types
"abort",
"error",
"load",
"timeout"
};
for (uint32_t index = 0; index < MOZ_ARRAY_LENGTH(sEventStrings); index++) {
nsAutoString eventType = NS_ConvertASCIItoUTF16(sEventStrings[index]);
rv = target->AddEventListener(eventType, listener, false);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = xhr->Send(variant);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:60,代码来源:UploadStumbleRunnable.cpp
示例6: void
void
BluetoothDaemonA2dpModule::HandleRsp(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU,
void* aUserData)
{
static void (BluetoothDaemonA2dpModule::* const HandleRsp[])(
const BluetoothDaemonPDUHeader&,
BluetoothDaemonPDU&,
BluetoothA2dpResultHandler*) = {
INIT_ARRAY_AT(OPCODE_ERROR,
&BluetoothDaemonA2dpModule::ErrorRsp),
INIT_ARRAY_AT(OPCODE_CONNECT,
&BluetoothDaemonA2dpModule::ConnectRsp),
INIT_ARRAY_AT(OPCODE_DISCONNECT,
&BluetoothDaemonA2dpModule::DisconnectRsp),
};
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
if (NS_WARN_IF(!(aHeader.mOpcode < MOZ_ARRAY_LENGTH(HandleRsp))) ||
NS_WARN_IF(!HandleRsp[aHeader.mOpcode])) {
return;
}
nsRefPtr<BluetoothA2dpResultHandler> res =
already_AddRefed<BluetoothA2dpResultHandler>(
static_cast<BluetoothA2dpResultHandler*>(aUserData));
if (!res) {
return; // Return early if no result handler has been set for response
}
(this->*(HandleRsp[aHeader.mOpcode]))(aHeader, aPDU, res);
}
开发者ID:AOSC-Dev,项目名称:Pale-Moon,代码行数:34,代码来源:BluetoothDaemonA2dpInterface.cpp
示例7: CreateTestH264Decoder
static already_AddRefed<MediaDataDecoder>
CreateTestH264Decoder(layers::LayersBackend aBackend,
VideoInfo& aConfig)
{
aConfig.mMimeType = "video/avc";
aConfig.mId = 1;
aConfig.mDuration = 40000;
aConfig.mMediaTime = 0;
aConfig.mDisplay = nsIntSize(64, 64);
aConfig.mImage = nsIntRect(0, 0, 64, 64);
aConfig.mExtraData = new MediaByteBuffer();
aConfig.mExtraData->AppendElements(sTestH264ExtraData,
MOZ_ARRAY_LENGTH(sTestH264ExtraData));
PlatformDecoderModule::Init();
nsRefPtr<PlatformDecoderModule> platform = PlatformDecoderModule::Create();
if (!platform) {
return nullptr;
}
nsRefPtr<MediaDataDecoder> decoder(
platform->CreateDecoder(aConfig, nullptr, nullptr, aBackend, nullptr));
if (!decoder) {
return nullptr;
}
return decoder.forget();
}
开发者ID:Jinwoo-Song,项目名称:gecko-dev,代码行数:29,代码来源:MP4Decoder.cpp
示例8: is_inaccessible
inline int
is_inaccessible(const char* aPropName)
{
for (unsigned j = 0; j < MOZ_ARRAY_LENGTH(gInaccessibleProperties); ++j) {
if (strcmp(aPropName, gInaccessibleProperties[j]) == 0)
return 1;
}
return 0;
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:9,代码来源:ListCSSProperties.cpp
示例9: GetFeatureInfo
static inline const FeatureInfo&
GetFeatureInfo(GLFeature feature)
{
static_assert(MOZ_ARRAY_LENGTH(sFeatureInfoArr) == size_t(GLFeature::EnumMax),
"Mismatched lengths for sFeatureInfoInfos and GLFeature enums");
MOZ_ASSERT(feature < GLFeature::EnumMax,
"GLContext::GetFeatureInfoInfo : unknown <feature>");
return sFeatureInfoArr[size_t(feature)];
}
开发者ID:CodeSpeaker,项目名称:gecko-dev,代码行数:11,代码来源:GLContextFeatures.cpp
示例10: GetExtensionGroupInfo
static inline const ExtensionGroupInfo&
GetExtensionGroupInfo(GLContext::GLExtensionGroup extensionGroup)
{
static_assert(MOZ_ARRAY_LENGTH(sExtensionGroupInfoArr) == size_t(GLContext::ExtensionGroup_Max),
"Mismatched lengths for sExtensionGroupInfos and ExtensionGroup enums");
MOZ_ASSERT(extensionGroup < GLContext::ExtensionGroup_Max,
"GLContext::GetExtensionGroupInfo : unknown <extensionGroup>");
return sExtensionGroupInfoArr[extensionGroup];
}
开发者ID:matyapiro31,项目名称:instantbird-1.5,代码行数:11,代码来源:GLContextExtensionGroupQueries.cpp
示例11: Convert
nsresult
Convert(const nsAString& aIn, bt_bdaddr_t& aOut)
{
NS_ConvertUTF16toUTF8 bdAddressUTF8(aIn);
const char* str = bdAddressUTF8.get();
for (size_t i = 0; i < MOZ_ARRAY_LENGTH(aOut.address); ++i, ++str) {
aOut.address[i] =
static_cast<uint8_t>(strtoul(str, const_cast<char**>(&str), 16));
}
return NS_OK;
}
开发者ID:atilag,项目名称:Gecko,代码行数:13,代码来源:BluetoothHALHelpers.cpp
示例12: STUMBLER_ERR
NS_IMETHODIMP
UploadEventListener::HandleEvent(nsIDOMEvent* aEvent)
{
nsString type;
if (NS_FAILED(aEvent->GetType(type))) {
STUMBLER_ERR("Failed to get event type");
WriteStumbleOnThread::UploadEnded(false);
return NS_ERROR_FAILURE;
}
if (type.EqualsLiteral("load")) {
STUMBLER_DBG("Got load Event\n");
} else if (type.EqualsLiteral("error") && mXHR) {
STUMBLER_ERR("Upload Error");
} else {
STUMBLER_DBG("Receive %s Event", NS_ConvertUTF16toUTF8(type).get());
}
uint32_t statusCode = 0;
bool doDelete = false;
if (!mXHR) {
return NS_OK;
}
nsresult rv = mXHR->GetStatus(&statusCode);
if (NS_SUCCEEDED(rv)) {
STUMBLER_DBG("statuscode %d \n", statusCode);
}
if (200 == statusCode || 400 == statusCode) {
doDelete = true;
}
WriteStumbleOnThread::UploadEnded(doDelete);
nsCOMPtr<EventTarget> target(do_QueryInterface(mXHR));
const char* const sEventStrings[] = {
// nsIXMLHttpRequestEventTarget event types
"abort",
"error",
"load",
"timeout"
};
for (uint32_t index = 0; index < MOZ_ARRAY_LENGTH(sEventStrings); index++) {
nsAutoString eventType = NS_ConvertASCIItoUTF16(sEventStrings[index]);
rv = target->RemoveEventListener(eventType, this, false);
}
mXHR = nullptr;
return NS_OK;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:51,代码来源:UploadStumbleRunnable.cpp
注:本文中的MOZ_ARRAY_LENGTH函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论