本文整理汇总了C++中LOG_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ LOG_ASSERT函数的具体用法?C++ LOG_ASSERT怎么用?C++ LOG_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LOG_ASSERT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
HIR::TypeRef HIR::TypeRef::get_field(size_t idx, size_t& ofs) const
{
if( const auto* w = this->get_wrapper() )
{
if( w->type == TypeWrapper::Ty::Slice )
{
// TODO
throw "TODO";
}
else if( w->type == TypeWrapper::Ty::Array )
{
LOG_ASSERT(idx < w->size, "Getting field on array with OOB index - " << idx << " >= " << w->size << " - " << *this);
auto ity = this->get_inner();
ofs = ity.get_size() * idx;
return ity;
}
else
{
throw "ERROR";
}
}
else
{
if( this->inner_type == RawType::Composite )
{
LOG_ASSERT(idx < this->composite_type->fields.size(), "Field " << idx << " out of bounds in type " << *this);
ofs = this->composite_type->fields.at(idx).first;
return this->composite_type->fields.at(idx).second;
}
else
{
::std::cerr << *this << " doesn't have fields" << ::std::endl;
throw "ERROR";
}
}
}
示例2: registerWebHistory
int registerWebHistory(JNIEnv* env)
{
// Get notified of all changes to history items.
WebCore::notifyHistoryItemChanged = historyItemChanged;
#ifdef UNIT_TEST
unit_test();
#endif
// Find WebHistoryItem, its constructor, and the update method.
jclass clazz = env->FindClass("android/webkit/WebHistoryItem");
LOG_ASSERT(clazz, "Unable to find class android/webkit/WebHistoryItem");
gWebHistoryItem.mInit = env->GetMethodID(clazz, "<init>", "()V");
LOG_ASSERT(gWebHistoryItem.mInit, "Could not find WebHistoryItem constructor");
gWebHistoryItem.mUpdate = env->GetMethodID(clazz, "update",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/graphics/Bitmap;[B)V");
LOG_ASSERT(gWebHistoryItem.mUpdate, "Could not find method update in WebHistoryItem");
// Find the field ids for mTitle and mUrl.
gWebHistoryItem.mTitle = env->GetFieldID(clazz, "mTitle", "Ljava/lang/String;");
LOG_ASSERT(gWebHistoryItem.mTitle, "Could not find field mTitle in WebHistoryItem");
gWebHistoryItem.mUrl = env->GetFieldID(clazz, "mUrl", "Ljava/lang/String;");
LOG_ASSERT(gWebHistoryItem.mUrl, "Could not find field mUrl in WebHistoryItem");
env->DeleteLocalRef(clazz);
// Find the WebBackForwardList object and method.
clazz = env->FindClass("android/webkit/WebBackForwardList");
LOG_ASSERT(clazz, "Unable to find class android/webkit/WebBackForwardList");
gWebBackForwardList.mAddHistoryItem = env->GetMethodID(clazz, "addHistoryItem",
"(Landroid/webkit/WebHistoryItem;)V");
LOG_ASSERT(gWebBackForwardList.mAddHistoryItem, "Could not find method addHistoryItem");
gWebBackForwardList.mRemoveHistoryItem = env->GetMethodID(clazz, "removeHistoryItem",
"(I)V");
LOG_ASSERT(gWebBackForwardList.mRemoveHistoryItem, "Could not find method removeHistoryItem");
gWebBackForwardList.mSetCurrentIndex = env->GetMethodID(clazz, "setCurrentIndex", "(I)V");
LOG_ASSERT(gWebBackForwardList.mSetCurrentIndex, "Could not find method setCurrentIndex");
env->DeleteLocalRef(clazz);
int result = jniRegisterNativeMethods(env, "android/webkit/WebBackForwardList",
gWebBackForwardListMethods, NELEM(gWebBackForwardListMethods));
return (result < 0) ? result : jniRegisterNativeMethods(env, "android/webkit/WebHistoryItem",
gWebHistoryItemMethods, NELEM(gWebHistoryItemMethods));
}
示例3: LOG_ASSERT
ssize_t VectorImpl::replaceAt(const void* prototype, size_t index)
{
LOG_ASSERT(index<size(),
"[%p] replace: index=%d, size=%d", this, (int)index, (int)size());
void* item = editItemLocation(index);
if (item == 0)
return NO_MEMORY;
_do_destroy(item, 1);
if (prototype == 0) {
_do_construct(item, 1);
} else {
_do_copy(item, prototype, 1);
}
return ssize_t(index);
}
示例4: counter
void WebCoreResourceLoader::Error(JNIEnv* env, jobject obj, jint id, jstring description,
jstring failingUrl)
{
#ifdef ANDROID_INSTRUMENT
TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
#endif
LOGV("webcore_resourceloader error");
WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj);
LOG_ASSERT(handle, "nativeError must take a valid handle!");
// ResourceLoader::didFail() can set handle to be NULL, we need to check
if (!handle)
return;
handle->client()->didFail(handle, WebCore::ResourceError("", id,
to_string(env, failingUrl), to_string(env, description)));
}
示例5: allocFromUTF8
static char* allocFromUTF8(const char* in, size_t len)
{
if (len > 0) {
SharedBuffer* buf = SharedBuffer::alloc(len+1);
LOG_ASSERT(buf, "Unable to allocate shared buffer");
if (buf) {
char* str = (char*)buf->data();
memcpy(str, in, len);
str[len] = 0;
return str;
}
return NULL;
}
return getEmptyString();
}
示例6: LOG_ASSERT
void Loading::loadTheBackgroundTexture()
{
LOG_ASSERT(NULL != gfx);
if (!lp_CONFIG->skin_name.empty() && TA3D::Paths::Exists(lp_CONFIG->skin_name))
{
SKIN skin;
skin.load_tdf(lp_CONFIG->skin_name);
if (!skin.prefix.empty())
pBackgroundTexture = gfx->load_texture_mask("gfx" + Paths::SeparatorAsString + "load.jpg", 7);
else
pBackgroundTexture = gfx->load_texture_mask("gfx" + Paths::SeparatorAsString + "load.jpg", 7);
}
else
pBackgroundTexture = gfx->load_texture_mask("gfx" + Paths::SeparatorAsString + "load.jpg", 7);
}
示例7: OkState
OkState
RpcServerManager::removeRemote(const std::string &name, const std::string &spec)
{
const NamedService *old = _rpcsrvmap.lookup(name);
if (old == nullptr) {
// was alright already, remove any reservation too
_rpcsrvmap.removeReservation(name);
return OkState(0, "already done");
}
if (old->getSpec() != spec) {
return OkState(1, "name registered, but with different spec");
}
std::unique_ptr<NamedService> td = _rpcsrvmap.remove(name);
LOG_ASSERT(td.get() == old);
return OkState(0, "done");
}
示例8: BREAK_IF
Data FileUtils::readDataFromZip(const std::string& zipFilePath, const std::string& filename, size_t *size)
{
Data retData;
unzFile file = nullptr;
*size = 0;
do
{
BREAK_IF(zipFilePath.empty());
file = unzOpen(zipFilePath.c_str());
BREAK_IF(!file);
// FIXME: Other platforms should use upstream minizip like mingw-w64
#ifdef MINIZIP_FROM_SYSTEM
int ret = unzLocateFile(file, filename.c_str(), NULL);
#else
int ret = unzLocateFile(file, filename.c_str(), 1);
#endif
BREAK_IF(UNZ_OK != ret);
char filePathA[260];
unz_file_info fileInfo;
ret = unzGetCurrentFileInfo(file, &fileInfo, filePathA, sizeof(filePathA), nullptr, 0, nullptr, 0);
BREAK_IF(UNZ_OK != ret);
ret = unzOpenCurrentFile(file);
BREAK_IF(UNZ_OK != ret);
unsigned char * buffer = (unsigned char*)malloc(fileInfo.uncompressed_size);
int readedSize = unzReadCurrentFile(file, buffer, static_cast<unsigned>(fileInfo.uncompressed_size));
LOG_ASSERT(readedSize == 0 || readedSize == (int)fileInfo.uncompressed_size, "the file size is wrong");
UNUSED_ARG(readedSize);
*size = fileInfo.uncompressed_size;
unzCloseCurrentFile(file);
retData.fastSet(buffer, *size, true);
} while (0);
if (file)
{
unzClose(file);
}
return retData;
}
示例9: switch
size_t
GenericHeader::Tag::getSize() const
{
size_t ret = _name.size() + 2;
switch (_type) {
case TYPE_FLOAT:
case TYPE_INTEGER:
ret += 8;
break;
case TYPE_STRING:
ret += _sVal.size() + 1;
break;
default:
LOG_ASSERT(false);
}
return ret;
}
示例10: android_atomic_dec
void RefBase::decStrong(const void* id) const
{
weakref_impl* const refs = mRefs;
refs->removeStrongRef(id);
const int32_t c = android_atomic_dec(&refs->mStrong);
#if PRINT_REFS
LOGD("decStrong of %p from %p: cnt=%d\n", this, id, c);
#endif
LOG_ASSERT(c >= 1, "decStrong() called on %p too many times", refs);
if (c == 1) {
refs->mBase->onLastStrongRef(id);
if ((refs->mFlags&OBJECT_LIFETIME_MASK) == OBJECT_LIFETIME_STRONG) {
delete this;
}
}
refs->decWeak(id);
}
示例11: gethostbyname
//
// BaseSocketManager::GetHostByName - Chapter 19, page 683
//
unsigned int BaseSocketManager::GetHostByName(const std::string &hostName)
{
//This will retrieve the ip details and put it into pHostEnt structure
struct hostent *pHostEnt = gethostbyname(hostName.c_str());
struct sockaddr_in tmpSockAddr; //placeholder for the ip address
if(pHostEnt == NULL)
{
LOG_ASSERT(0 && _T("Error occured"));
return 0;
}
tmpSockAddr.sin_addr.s_addr = *(u_long *)pHostEnt->h_addr;
//char* test = inet_ntoa(tmpSockAddr.sin_addr);
//memcpy(&tmpSockAddr.sin_addr,pHostEnt->h_addr,pHostEnt->h_length);
return ntohl(tmpSockAddr.sin_addr.s_addr);
}
示例12: printf
bool FileAllocator::attach(FILE *f, FileOffset reserved_space, bool init)
{
#ifdef DEBUG_FA
printf("FileAllocator::attach()\n");
#endif
LOG_ASSERT(f != 0);
this->f = f;
this->reserved_space = reserved_space;
if (fseek(this->f, 0, SEEK_END))
throw GenericException(__FILE__, __LINE__, "fseek error");
file_size = ftell(this->f);
if (file_size < 0)
throw GenericException(__FILE__, __LINE__, "ftell error");
// File size should be
// 0 for new file or at least reserved_space + list headers
if (file_size == 0)
{
if (init == false)
throw GenericException(__FILE__, __LINE__,
"FileAllocator in read-only mode found empty file");
// create empty list headers
memset(&allocated_head, 0, list_node_size);
memset(&free_head, 0, list_node_size);
write_node(this->reserved_space, &allocated_head);
write_node(this->reserved_space+list_node_size, &free_head);
file_size = ftell(this->f);
FileOffset expected = reserved_space + 2*list_node_size;
if (file_size != expected)
throw GenericException(__FILE__, __LINE__,
"Initialization error: "
"Expected file size %ld, found %ld",
(long) expected, (long) file_size);
return true;
}
FileOffset expected = this->reserved_space + 2*list_node_size;
if (file_size < expected)
throw GenericException(__FILE__, __LINE__,
"FileAllocator: Broken file header,"
"expected at least %ld bytes",
(long) expected);
// read existing list headers
read_node(this->reserved_space, &allocated_head);
read_node(this->reserved_space+list_node_size, &free_head);
return false; // Didn't initialize the file
}
示例13: LOG_ASSERT
bool FileUtils::writeDataToFile(Data retData, const std::string& fullPath)
{
LOG_ASSERT(!fullPath.empty() && retData.getSize() != 0, "Invalid parameters.");
do
{
size_t size = 0;
const char* mode = "wb";
// Read the file from hardware
FILE *fp = fopen(fullPath.c_str(), mode);
BREAK_IF(!fp);
size = retData.getSize();
fwrite(retData.getBytes(), size, 1, fp);
fclose(fp);
return true;
} while (0);
return false;
}
示例14: android_atomic_inc
void RefBase::incStrong(const void* id) const
{
weakref_impl* const refs = mRefs;
refs->incWeak(id);
refs->addStrongRef(id);
const int32_t c = android_atomic_inc(&refs->mStrong);
LOG_ASSERT(c > 0, "incStrong() called on %p after last strong ref", refs);
#if PRINT_REFS
LOGD("incStrong of %p from %p: cnt=%d\n", this, id, c);
#endif
if (c != INITIAL_STRONG_VALUE) {
return;
}
android_atomic_add(-INITIAL_STRONG_VALUE, &refs->mStrong);
refs->mBase->onFirstRef();
}
示例15: allocFromUTF16
static char* allocFromUTF16(const char16_t* in, size_t len)
{
if (len == 0) return getEmptyString();
const size_t bytes = utf8_length_from_utf16(in, len);
SharedBuffer* buf = SharedBuffer::alloc(bytes+1);
LOG_ASSERT(buf, "Unable to allocate shared buffer");
if (buf) {
char* str = (char*)buf->data();
utf16_to_utf8(in, len, str, bytes+1);
return str;
}
return getEmptyString();
}