Skip to content

Commit

Permalink
RRenamed BX_CHECK to BX_ASSERT.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed Jun 16, 2020
1 parent 7bf14f0 commit f888abe
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 78 deletions.
6 changes: 3 additions & 3 deletions include/bx/inline/error.inl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace bx

inline void Error::setError(ErrorResult _errorResult, const StringView& _msg)
{
BX_CHECK(0 != _errorResult.code, "Invalid ErrorResult passed to setError!");
BX_ASSERT(0 != _errorResult.code, "Invalid ErrorResult passed to setError!");

if (!isOk() )
{
Expand Down Expand Up @@ -62,12 +62,12 @@ namespace bx
inline ErrorScope::ErrorScope(Error* _err)
: m_err(_err)
{
BX_CHECK(NULL != _err, "_err can't be NULL");
BX_ASSERT(NULL != _err, "_err can't be NULL");
}

inline ErrorScope::~ErrorScope()
{
BX_CHECK(m_err->isOk(), "Error: %d", m_err->get().code);
BX_ASSERT(m_err->isOk(), "Error: %d", m_err->get().code);
}

} // namespace bx
10 changes: 5 additions & 5 deletions include/bx/inline/handlealloc.inl
Original file line number Diff line number Diff line change
Expand Up @@ -186,23 +186,23 @@ namespace bx
template <uint16_t MaxHandlesT>
inline uint16_t HandleListT<MaxHandlesT>::getNext(uint16_t _handle) const
{
BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
BX_ASSERT(isValid(_handle), "Invalid handle %d!", _handle);
const Link& curr = m_links[_handle];
return curr.m_next;
}

template <uint16_t MaxHandlesT>
inline uint16_t HandleListT<MaxHandlesT>::getPrev(uint16_t _handle) const
{
BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
BX_ASSERT(isValid(_handle), "Invalid handle %d!", _handle);
const Link& curr = m_links[_handle];
return curr.m_prev;
}

template <uint16_t MaxHandlesT>
inline void HandleListT<MaxHandlesT>::remove(uint16_t _handle)
{
BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
BX_ASSERT(isValid(_handle), "Invalid handle %d!", _handle);
Link& curr = m_links[_handle];

if (kInvalidHandle != curr.m_prev)
Expand Down Expand Up @@ -358,15 +358,15 @@ namespace bx
template <uint16_t MaxHandlesT>
inline void HandleAllocLruT<MaxHandlesT>::free(uint16_t _handle)
{
BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
BX_ASSERT(isValid(_handle), "Invalid handle %d!", _handle);
m_list.remove(_handle);
m_alloc.free(_handle);
}

template <uint16_t MaxHandlesT>
inline void HandleAllocLruT<MaxHandlesT>::touch(uint16_t _handle)
{
BX_CHECK(isValid(_handle), "Invalid handle %d!", _handle);
BX_ASSERT(isValid(_handle), "Invalid handle %d!", _handle);
m_list.remove(_handle);
m_list.pushFront(_handle);
}
Expand Down
6 changes: 3 additions & 3 deletions include/bx/inline/readerwriter.inl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace bx

inline int32_t SizerWriter::write(const void* /*_data*/, int32_t _size, Error* _err)
{
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

int32_t morecore = int32_t(m_pos - m_top) + _size;

Expand Down Expand Up @@ -170,7 +170,7 @@ namespace bx

inline int32_t MemoryReader::read(void* _data, int32_t _size, Error* _err)
{
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

int64_t remainder = m_top-m_pos;
int32_t size = uint32_min(_size, uint32_t(min<int64_t>(remainder, INT32_MAX) ) );
Expand Down Expand Up @@ -233,7 +233,7 @@ namespace bx

inline int32_t MemoryWriter::write(const void* _data, int32_t _size, Error* _err)
{
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

int32_t morecore = int32_t(m_pos - m_size) + _size;

Expand Down
4 changes: 2 additions & 2 deletions include/bx/inline/ringbuffer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace bx
, m_size(_size)
, m_buffer(_buffer)
{
BX_CHECK(_control.available() >= _size, "%d >= %d", _control.available(), _size);
BX_ASSERT(_control.available() >= _size, "%d >= %d", _control.available(), _size);
}

template <typename ControlT>
Expand Down Expand Up @@ -210,7 +210,7 @@ namespace bx
{
uint32_t size = m_control.reserve(_size);
BX_UNUSED(size);
BX_CHECK(size == _size, "%d == %d", size, _size);
BX_ASSERT(size == _size, "%d == %d", size, _size);
m_write = m_control.m_current;
m_end = m_write+_size;
}
Expand Down
2 changes: 1 addition & 1 deletion include/bx/inline/rng.inl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace bx
template<typename Rng, typename Ty>
inline void shuffle(Rng* _rng, Ty* _array, uint32_t _num)
{
BX_CHECK(_num != 0, "Number of elements can't be 0!");
BX_ASSERT(_num != 0, "Number of elements can't be 0!");

for (uint32_t ii = 0, num = _num-1; ii < num; ++ii)
{
Expand Down
8 changes: 4 additions & 4 deletions include/bx/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,17 @@
# define BX_CLASS(_class, ...) BX_MACRO_DISPATCHER(BX_CLASS_, __VA_ARGS__)(_class, __VA_ARGS__)
#endif // BX_COMPILER_MSVC

#ifndef BX_CHECK
# define BX_CHECK(_condition, ...) BX_NOOP()
#endif // BX_CHECK
#ifndef BX_ASSERT
# define BX_ASSERT(_condition, ...) BX_NOOP()
#endif // BX_ASSERT

#ifndef BX_TRACE
# define BX_TRACE(...) BX_NOOP()
#endif // BX_TRACE

#ifndef BX_WARN
# define BX_WARN(_condition, ...) BX_NOOP()
#endif // BX_CHECK
#endif // BX_ASSERT

// static_assert sometimes causes unused-local-typedef...
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG("-Wunused-local-typedef")
Expand Down
4 changes: 2 additions & 2 deletions src/bx_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#if BX_CONFIG_DEBUG
# define BX_TRACE _BX_TRACE
# define BX_WARN _BX_WARN
# define BX_CHECK _BX_CHECK
# define BX_ASSERT _BX_ASSERT
# define BX_CONFIG_ALLOCATOR_DEBUG 1
#endif // BX_CONFIG_DEBUG

Expand All @@ -30,7 +30,7 @@
} \
BX_MACRO_BLOCK_END

#define _BX_CHECK(_condition, _format, ...) \
#define _BX_ASSERT(_condition, _format, ...) \
BX_MACRO_BLOCK_BEGIN \
if (!BX_IGNORE_C4127(_condition) ) \
{ \
Expand Down
2 changes: 1 addition & 1 deletion src/crtnone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ extern "C" const char* strstr(const char* _str, const char* _find)

extern "C" void qsort(void* _base, size_t _num, size_t _size, bx::ComparisonFn _fn)
{
BX_CHECK(_num <= UINT32_MAX && _size <= UINT32_MAX, "");
BX_ASSERT(_num <= UINT32_MAX && _size <= UINT32_MAX, "");
return bx::quickSort(_base, _num, _size, _fn);
}

Expand Down
6 changes: 3 additions & 3 deletions src/dtoa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ namespace bx

DiyFp operator-(const DiyFp& rhs) const
{
BX_CHECK(e == rhs.e, "");
BX_CHECK(f >= rhs.f, "");
BX_ASSERT(e == rhs.e, "");
BX_ASSERT(f >= rhs.f, "");
return DiyFp(f - rhs.f, e);
}

Expand Down Expand Up @@ -224,7 +224,7 @@ namespace bx
uint32_t index = static_cast<uint32_t>( (k >> 3) + 1);
*K = -(-348 + static_cast<int32_t>(index << 3) ); // decimal exponent no need lookup table

BX_CHECK(index < sizeof(s_kCachedPowers_F) / sizeof(s_kCachedPowers_F[0]), "");
BX_ASSERT(index < sizeof(s_kCachedPowers_F) / sizeof(s_kCachedPowers_F[0]), "");
return DiyFp(s_kCachedPowers_F[index], s_kCachedPowers_E[index]);
}

Expand Down
38 changes: 19 additions & 19 deletions src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace bx

virtual bool open(const FilePath& _filePath, Error* _err) override
{
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

if (NULL != m_file)
{
Expand Down Expand Up @@ -131,15 +131,15 @@ namespace bx

virtual int64_t seek(int64_t _offset, Whence::Enum _whence) override
{
BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
BX_ASSERT(NULL != m_file, "Reader/Writer file is not open.");
fseeko64(m_file, _offset, _whence);
return ftello64(m_file);
}

virtual int32_t read(void* _data, int32_t _size, Error* _err) override
{
BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != m_file, "Reader/Writer file is not open.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

int32_t size = (int32_t)fread(_data, 1, _size, m_file);
if (size != _size)
Expand Down Expand Up @@ -180,7 +180,7 @@ namespace bx

virtual bool open(const FilePath& _filePath, bool _append, Error* _err) override
{
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

if (NULL != m_file)
{
Expand Down Expand Up @@ -212,15 +212,15 @@ namespace bx

virtual int64_t seek(int64_t _offset, Whence::Enum _whence) override
{
BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
BX_ASSERT(NULL != m_file, "Reader/Writer file is not open.");
fseeko64(m_file, _offset, _whence);
return ftello64(m_file);
}

virtual int32_t write(const void* _data, int32_t _size, Error* _err) override
{
BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != m_file, "Reader/Writer file is not open.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

int32_t size = (int32_t)fwrite(_data, 1, _size, m_file);
if (size != _size)
Expand Down Expand Up @@ -272,7 +272,7 @@ namespace bx

virtual bool open(const FilePath& _filePath, Error* _err) override
{
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

if (0 != m_fd)
{
Expand Down Expand Up @@ -304,14 +304,14 @@ namespace bx

virtual int64_t seek(int64_t _offset, Whence::Enum _whence) override
{
BX_CHECK(0 != m_fd, "Reader/Writer file is not open.");
BX_ASSERT(0 != m_fd, "Reader/Writer file is not open.");
return crt0::seek(m_fd, _offset, crt0::Whence::Enum(_whence) );
}

virtual int32_t read(void* _data, int32_t _size, Error* _err) override
{
BX_CHECK(0 != m_fd, "Reader/Writer file is not open.");
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(0 != m_fd, "Reader/Writer file is not open.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

int32_t size = crt0::read(m_fd, _data, _size);
if (size != _size)
Expand Down Expand Up @@ -353,7 +353,7 @@ namespace bx

virtual bool open(const FilePath& _filePath, bool _append, Error* _err) override
{
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

if (0 != m_fd)
{
Expand Down Expand Up @@ -385,14 +385,14 @@ namespace bx

virtual int64_t seek(int64_t _offset, Whence::Enum _whence) override
{
BX_CHECK(0 != m_fd, "Reader/Writer file is not open.");
BX_ASSERT(0 != m_fd, "Reader/Writer file is not open.");
return crt0::seek(m_fd, _offset, crt0::Whence::Enum(_whence) );
}

virtual int32_t write(const void* _data, int32_t _size, Error* _err) override
{
BX_CHECK(0 != m_fd, "Reader/Writer file is not open.");
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(0 != m_fd, "Reader/Writer file is not open.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

int32_t size = crt0::write(m_fd, _data, _size);
if (size != _size)
Expand Down Expand Up @@ -582,7 +582,7 @@ namespace bx

virtual bool open(const FilePath& _filePath, Error* _err) override
{
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

m_dir = opendir(_filePath.getCPtr() );

Expand All @@ -608,7 +608,7 @@ namespace bx

virtual int32_t read(void* _data, int32_t _size, Error* _err) override
{
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

int32_t total = 0;

Expand Down Expand Up @@ -701,7 +701,7 @@ namespace bx
virtual int32_t read(void* _data, int32_t _size, Error* _err) override
{
BX_UNUSED(_data, _size);
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ERROR_SET(_err, BX_ERROR_READERWRITER_EOF, "DirectoryReader: EOF.");
return 0;
}
Expand Down
16 changes: 8 additions & 8 deletions src/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ namespace bx

ProcessReader::~ProcessReader()
{
BX_CHECK(NULL == m_file, "Process not closed!");
BX_ASSERT(NULL == m_file, "Process not closed!");
}

bool ProcessReader::open(const FilePath& _filePath, const StringView& _args, Error* _err)
{
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

if (NULL != m_file)
{
Expand All @@ -64,15 +64,15 @@ namespace bx

void ProcessReader::close()
{
BX_CHECK(NULL != m_file, "Process not open!");
BX_ASSERT(NULL != m_file, "Process not open!");
FILE* file = (FILE*)m_file;
m_exitCode = pclose(file);
m_file = NULL;
}

int32_t ProcessReader::read(void* _data, int32_t _size, Error* _err)
{
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err);
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err);

FILE* file = (FILE*)m_file;
int32_t size = (int32_t)fread(_data, 1, _size, file);
Expand Down Expand Up @@ -105,12 +105,12 @@ namespace bx

ProcessWriter::~ProcessWriter()
{
BX_CHECK(NULL == m_file, "Process not closed!");
BX_ASSERT(NULL == m_file, "Process not closed!");
}

bool ProcessWriter::open(const FilePath& _filePath, const StringView& _args, Error* _err)
{
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");

if (NULL != m_file)
{
Expand All @@ -135,15 +135,15 @@ namespace bx

void ProcessWriter::close()
{
BX_CHECK(NULL != m_file, "Process not open!");
BX_ASSERT(NULL != m_file, "Process not open!");
FILE* file = (FILE*)m_file;
m_exitCode = pclose(file);
m_file = NULL;
}

int32_t ProcessWriter::write(const void* _data, int32_t _size, Error* _err)
{
BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err);
BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors."); BX_UNUSED(_err);

FILE* file = (FILE*)m_file;
int32_t size = (int32_t)fwrite(_data, 1, _size, file);
Expand Down
Loading

0 comments on commit f888abe

Please sign in to comment.