diff --git a/engine/dynamic/render_opengl/src/gl_util.cpp b/engine/dynamic/render_opengl/src/gl_util.cpp index e4b127e9..44dd981c 100644 --- a/engine/dynamic/render_opengl/src/gl_util.cpp +++ b/engine/dynamic/render_opengl/src/gl_util.cpp @@ -77,7 +77,7 @@ namespace argus { void set_attrib_pointer(array_handle_t array_obj, buffer_handle_t buffer_obj, binding_index_t binding_index, GLuint vertex_len, GLuint attr_len, GLuint attr_index, GLuint *attr_offset) { - assert(attr_len <= INT_MAX); + argus_assert(attr_len <= INT_MAX); if (AGLET_GL_ARB_direct_state_access) { glEnableVertexArrayAttrib(array_obj, attr_index); @@ -85,7 +85,7 @@ namespace argus { glVertexArrayAttribBinding(array_obj, attr_index, binding_index); } else { auto stride = vertex_len * uint32_t(sizeof(GLfloat)); - assert(stride <= INT_MAX); + argus_assert(stride <= INT_MAX); glBindBuffer(GL_ARRAY_BUFFER, buffer_obj); glEnableVertexAttribArray(attr_index); diff --git a/engine/dynamic/render_opengl/src/module_render_opengl.cpp b/engine/dynamic/render_opengl/src/module_render_opengl.cpp index 722c803d..55825dd7 100644 --- a/engine/dynamic/render_opengl/src/module_render_opengl.cpp +++ b/engine/dynamic/render_opengl/src/module_render_opengl.cpp @@ -125,7 +125,7 @@ namespace argus { } auto it = g_renderer_map.find(&window); - assert(it != g_renderer_map.end()); + argus_assert(it != g_renderer_map.end()); it->second->render(event.delta); break; @@ -136,7 +136,7 @@ namespace argus { } auto it = g_renderer_map.find(&window); - assert(it != g_renderer_map.end()); + argus_assert(it != g_renderer_map.end()); it->second->notify_window_resize(event.resolution); break; diff --git a/engine/dynamic/render_opengl/src/renderer/bucket_proc.cpp b/engine/dynamic/render_opengl/src/renderer/bucket_proc.cpp index a23003d2..8fcf3a0c 100644 --- a/engine/dynamic/render_opengl/src/renderer/bucket_proc.cpp +++ b/engine/dynamic/render_opengl/src/renderer/bucket_proc.cpp @@ -57,7 +57,7 @@ namespace argus { } auto program_it = scene_state.parent_state.linked_programs.find(bucket->material_res.uid); - assert(program_it != scene_state.parent_state.linked_programs.cend()); + argus_assert(program_it != scene_state.parent_state.linked_programs.cend()); // the program should have been linked during object processing auto &program = program_it->second; diff --git a/engine/dynamic/render_opengl/src/renderer/buffer.cpp b/engine/dynamic/render_opengl/src/renderer/buffer.cpp index e99b34d6..7ead0330 100644 --- a/engine/dynamic/render_opengl/src/renderer/buffer.cpp +++ b/engine/dynamic/render_opengl/src/renderer/buffer.cpp @@ -76,14 +76,14 @@ namespace argus { } void BufferInfo::map_write() { - assert(valid); - assert(allow_mapping); + argus_assert(valid); + argus_assert(allow_mapping); if (persistent) { return; } - assert(mapped == nullptr); + argus_assert(mapped == nullptr); if (AGLET_GL_ARB_direct_state_access) { mapped = glMapNamedBuffer(handle, GL_WRITE_ONLY); @@ -95,14 +95,14 @@ namespace argus { } void BufferInfo::unmap() { - assert(valid); - assert(allow_mapping); + argus_assert(valid); + argus_assert(allow_mapping); if (persistent) { return; } - assert(mapped != nullptr); + argus_assert(mapped != nullptr); if (AGLET_GL_ARB_direct_state_access) { glUnmapNamedBuffer(handle); @@ -116,8 +116,8 @@ namespace argus { } void BufferInfo::write(void *src, size_t len, size_t offset) { - assert(valid); - assert(offset + len <= this->size); + argus_assert(valid); + argus_assert(offset + len <= this->size); if (mapped != nullptr) { memcpy(reinterpret_cast(reinterpret_cast(mapped) + offset), src, len); diff --git a/engine/dynamic/render_opengl/src/renderer/shader_mgmt.cpp b/engine/dynamic/render_opengl/src/renderer/shader_mgmt.cpp index 53e8d261..b0730fda 100644 --- a/engine/dynamic/render_opengl/src/renderer/shader_mgmt.cpp +++ b/engine/dynamic/render_opengl/src/renderer/shader_mgmt.cpp @@ -177,7 +177,7 @@ namespace argus { if (gl_res == GL_FALSE) { int log_len; glGetShaderiv(shader_handle, GL_INFO_LOG_LENGTH, &log_len); - assert(log_len >= 0); + argus_assert(log_len >= 0); char *log = new char[size_t(log_len) + 1]; log[0] = '\0'; glGetShaderInfoLog(shader_handle, log_len, nullptr, log); @@ -272,7 +272,7 @@ namespace argus { if (res == GL_FALSE) { int log_len; glGetProgramiv(program_handle, GL_INFO_LOG_LENGTH, &log_len); - assert(log_len >= 0); + argus_assert(log_len >= 0); char *log = new char[size_t(log_len)]; glGetProgramInfoLog(program_handle, GL_INFO_LOG_LENGTH, nullptr, log); crash("Failed to link program: %s", log); @@ -283,7 +283,7 @@ namespace argus { GLint attrib_count; glGetProgramiv(program_handle, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &attrib_max_len); - assert(attrib_max_len >= 0); + argus_assert(attrib_max_len >= 0); glGetProgramiv(program_handle, GL_ACTIVE_ATTRIBUTES, &attrib_count); GLsizei attrib_name_len; @@ -294,9 +294,9 @@ namespace argus { for (int i = 0; i < attrib_count; i++) { glGetActiveAttrib(program_handle, uint32_t(i), attrib_max_len, &attrib_name_len, &attrib_size, &attrib_type, attrib_name); - assert(attrib_name_len <= attrib_max_len); + argus_assert(attrib_name_len <= attrib_max_len); GLint attrib_loc = glGetAttribLocation(program_handle, attrib_name); - assert(attrib_loc >= 0); + argus_assert(attrib_loc >= 0); refl_info.attribute_locations[std::string(attrib_name)] = uint32_t(attrib_loc); } } @@ -306,7 +306,7 @@ namespace argus { GLint uniform_count; glGetProgramiv(program_handle, GL_ACTIVE_UNIFORM_MAX_LENGTH, &uniform_max_len); - assert(uniform_max_len >= 0); + argus_assert(uniform_max_len >= 0); glGetProgramiv(program_handle, GL_ACTIVE_UNIFORMS, &uniform_count); GLsizei uniform_name_len; @@ -315,9 +315,9 @@ namespace argus { for (int i = 0; i < uniform_count; i++) { glGetActiveUniformName(program_handle, uint32_t(i), uniform_max_len, &uniform_name_len, uniform_name); - assert(uniform_name_len <= uniform_max_len); + argus_assert(uniform_name_len <= uniform_max_len); GLint uniform_loc = glGetUniformLocation(program_handle, uniform_name); - assert(uniform_loc >= 0); + argus_assert(uniform_loc >= 0); refl_info.uniform_variable_locations[std::string(uniform_name)] = uint32_t(uniform_loc); } } diff --git a/engine/dynamic/render_opengl_legacy/src/gl_util.cpp b/engine/dynamic/render_opengl_legacy/src/gl_util.cpp index d0f2a8b0..bd56042c 100644 --- a/engine/dynamic/render_opengl_legacy/src/gl_util.cpp +++ b/engine/dynamic/render_opengl_legacy/src/gl_util.cpp @@ -33,10 +33,10 @@ namespace argus { void set_attrib_pointer(buffer_handle_t buffer_obj, GLuint vertex_len, GLuint attr_len, GLuint attr_index, GLuint *attr_offset) { - assert(attr_len <= INT_MAX); + argus_assert(attr_len <= INT_MAX); auto stride = vertex_len * uint32_t(sizeof(GLfloat)); - assert(stride <= INT_MAX); + argus_assert(stride <= INT_MAX); glBindBuffer(GL_ARRAY_BUFFER, buffer_obj); glEnableVertexAttribArray(attr_index); diff --git a/engine/dynamic/render_opengl_legacy/src/module_render_opengl_legacy.cpp b/engine/dynamic/render_opengl_legacy/src/module_render_opengl_legacy.cpp index 7c42999d..7dd1a6b8 100644 --- a/engine/dynamic/render_opengl_legacy/src/module_render_opengl_legacy.cpp +++ b/engine/dynamic/render_opengl_legacy/src/module_render_opengl_legacy.cpp @@ -127,7 +127,7 @@ namespace argus { } auto it = g_renderer_map.find(&window); - assert(it != g_renderer_map.end()); + argus_assert(it != g_renderer_map.end()); it->second->render(event.delta); break; @@ -138,7 +138,7 @@ namespace argus { } auto it = g_renderer_map.find(&window); - assert(it != g_renderer_map.end()); + argus_assert(it != g_renderer_map.end()); it->second->notify_window_resize(event.resolution); break; diff --git a/engine/dynamic/render_opengl_legacy/src/renderer/bucket_proc.cpp b/engine/dynamic/render_opengl_legacy/src/renderer/bucket_proc.cpp index 5f5aba89..507c12e5 100644 --- a/engine/dynamic/render_opengl_legacy/src/renderer/bucket_proc.cpp +++ b/engine/dynamic/render_opengl_legacy/src/renderer/bucket_proc.cpp @@ -101,7 +101,7 @@ namespace argus { } auto program_it = scene_state.parent_state.linked_programs.find(bucket->material_res.uid); - assert(program_it != scene_state.parent_state.linked_programs.cend()); + argus_assert(program_it != scene_state.parent_state.linked_programs.cend()); bool animated = program_it->second.reflection.has_uniform(SHADER_UBO_OBJ, SHADER_UNIFORM_OBJ_UV_STRIDE); diff --git a/engine/dynamic/render_opengl_legacy/src/renderer/shader_mgmt.cpp b/engine/dynamic/render_opengl_legacy/src/renderer/shader_mgmt.cpp index 14e9906e..6222a7ad 100644 --- a/engine/dynamic/render_opengl_legacy/src/renderer/shader_mgmt.cpp +++ b/engine/dynamic/render_opengl_legacy/src/renderer/shader_mgmt.cpp @@ -137,7 +137,7 @@ namespace argus { if (res == GL_FALSE) { int log_len; glGetShaderiv(shader_handle, GL_INFO_LOG_LENGTH, &log_len); - assert(log_len >= 0); + argus_assert(log_len >= 0); char *log = new char[size_t(log_len) + 1]; log[0] = '\0'; glGetShaderInfoLog(shader_handle, log_len, nullptr, log); @@ -227,7 +227,7 @@ namespace argus { if (res == GL_FALSE) { int log_len; glGetProgramiv(program_handle, GL_INFO_LOG_LENGTH, &log_len); - assert(log_len >= 0); + argus_assert(log_len >= 0); char *log = new char[size_t(log_len)]; glGetProgramInfoLog(program_handle, GL_INFO_LOG_LENGTH, nullptr, log); crash("Failed to link program: %s", log); @@ -237,7 +237,7 @@ namespace argus { GLint attrib_count; glGetProgramiv(program_handle, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &attrib_max_len); - assert(attrib_max_len >= 0); + argus_assert(attrib_max_len >= 0); glGetProgramiv(program_handle, GL_ACTIVE_ATTRIBUTES, &attrib_count); GLsizei attrib_name_len; @@ -248,9 +248,9 @@ namespace argus { for (int i = 0; i < attrib_count; i++) { glGetActiveAttrib(program_handle, uint32_t(i), attrib_max_len, &attrib_name_len, &attrib_size, &attrib_type, attrib_name); - assert(attrib_name_len <= attrib_max_len); + argus_assert(attrib_name_len <= attrib_max_len); GLint attrib_loc = glGetAttribLocation(program_handle, attrib_name); - assert(attrib_loc >= 0); + argus_assert(attrib_loc >= 0); refl_info.attribute_locations[std::string(attrib_name)] = uint32_t(attrib_loc); } @@ -258,7 +258,7 @@ namespace argus { GLint uniform_count; glGetProgramiv(program_handle, GL_ACTIVE_UNIFORM_MAX_LENGTH, &uniform_max_len); - assert(uniform_max_len >= 0); + argus_assert(uniform_max_len >= 0); glGetProgramiv(program_handle, GL_ACTIVE_UNIFORMS, &uniform_count); GLsizei uniform_name_len; @@ -267,9 +267,9 @@ namespace argus { for (int i = 0; i < uniform_count; i++) { glGetActiveUniform(program_handle, uint32_t(i), uniform_max_len, &uniform_name_len, nullptr, nullptr, uniform_name); - assert(uniform_name_len <= uniform_max_len); + argus_assert(uniform_name_len <= uniform_max_len); GLint uniform_loc = glGetUniformLocation(program_handle, uniform_name); - assert(uniform_loc >= 0); + argus_assert(uniform_loc >= 0); refl_info.uniform_variable_locations[std::string(uniform_name)] = uint32_t(uniform_loc); } diff --git a/engine/dynamic/render_opengles/src/gl_util.cpp b/engine/dynamic/render_opengles/src/gl_util.cpp index 914a13b2..0717c8c3 100644 --- a/engine/dynamic/render_opengles/src/gl_util.cpp +++ b/engine/dynamic/render_opengles/src/gl_util.cpp @@ -77,10 +77,10 @@ namespace argus { GLuint attr_len, GLuint attr_index, GLuint *attr_offset) { UNUSED(binding_index); - assert(attr_len <= INT_MAX); + argus_assert(attr_len <= INT_MAX); auto stride = vertex_len * uint32_t(sizeof(GLfloat)); - assert(stride <= INT_MAX); + argus_assert(stride <= INT_MAX); glBindBuffer(GL_ARRAY_BUFFER, buffer_obj); glEnableVertexAttribArray(attr_index); diff --git a/engine/dynamic/render_opengles/src/module_render_opengles.cpp b/engine/dynamic/render_opengles/src/module_render_opengles.cpp index 6fff67af..7c2ce384 100644 --- a/engine/dynamic/render_opengles/src/module_render_opengles.cpp +++ b/engine/dynamic/render_opengles/src/module_render_opengles.cpp @@ -122,7 +122,7 @@ namespace argus { } auto it = g_renderer_map.find(&window); - assert(it != g_renderer_map.end()); + argus_assert(it != g_renderer_map.end()); it->second->render(event.delta); break; @@ -133,7 +133,7 @@ namespace argus { } auto it = g_renderer_map.find(&window); - assert(it != g_renderer_map.end()); + argus_assert(it != g_renderer_map.end()); it->second->notify_window_resize(event.resolution); break; diff --git a/engine/dynamic/render_opengles/src/renderer/bucket_proc.cpp b/engine/dynamic/render_opengles/src/renderer/bucket_proc.cpp index f71ed787..a1e96032 100644 --- a/engine/dynamic/render_opengles/src/renderer/bucket_proc.cpp +++ b/engine/dynamic/render_opengles/src/renderer/bucket_proc.cpp @@ -56,7 +56,7 @@ namespace argus { } auto program_it = scene_state.parent_state.linked_programs.find(bucket->material_res.uid); - assert(program_it != scene_state.parent_state.linked_programs.cend()); + argus_assert(program_it != scene_state.parent_state.linked_programs.cend()); // the program should have been linked during object processing auto &program = program_it->second; diff --git a/engine/dynamic/render_opengles/src/renderer/buffer.cpp b/engine/dynamic/render_opengles/src/renderer/buffer.cpp index 0b3f5749..4b9d7635 100644 --- a/engine/dynamic/render_opengles/src/renderer/buffer.cpp +++ b/engine/dynamic/render_opengles/src/renderer/buffer.cpp @@ -57,13 +57,13 @@ namespace argus { } void BufferInfo::map_write() { - assert(valid); + argus_assert(valid); if (persistent) { return; } - assert(mapped == nullptr); + argus_assert(mapped == nullptr); glBindBuffer(target, handle); mapped = glMapBufferRange(target, 0, GLsizeiptr(size), GL_MAP_WRITE_BIT); @@ -71,13 +71,13 @@ namespace argus { } void BufferInfo::unmap() { - assert(valid); + argus_assert(valid); if (persistent) { return; } - assert(mapped != nullptr); + argus_assert(mapped != nullptr); glBindBuffer(target, handle); glUnmapBuffer(target); @@ -87,8 +87,8 @@ namespace argus { } void BufferInfo::write(void *src, size_t len, size_t offset) { - assert(valid); - assert(offset + len <= this->size); + argus_assert(valid); + argus_assert(offset + len <= this->size); if (mapped != nullptr) { memcpy(reinterpret_cast(reinterpret_cast(mapped) + offset), src, len); diff --git a/engine/dynamic/render_opengles/src/renderer/shader_mgmt.cpp b/engine/dynamic/render_opengles/src/renderer/shader_mgmt.cpp index 15993d9c..e7090e08 100644 --- a/engine/dynamic/render_opengles/src/renderer/shader_mgmt.cpp +++ b/engine/dynamic/render_opengles/src/renderer/shader_mgmt.cpp @@ -153,7 +153,7 @@ namespace argus { if (gl_res == GL_FALSE) { GLint log_len; glGetShaderiv(shader_handle, GL_INFO_LOG_LENGTH, &log_len); - assert(log_len >= 0); + argus_assert(log_len >= 0); char *log = new char[size_t(log_len + 1)]; glGetShaderInfoLog(shader_handle, log_len, nullptr, log); std::string stage_str; @@ -245,7 +245,7 @@ namespace argus { if (res == GL_FALSE) { int log_len; glGetProgramiv(program_handle, GL_INFO_LOG_LENGTH, &log_len); - assert(log_len >= 0); + argus_assert(log_len >= 0); char *log = new char[size_t(log_len)]; glGetProgramInfoLog(program_handle, GL_INFO_LOG_LENGTH, nullptr, log); crash("Failed to link program: %s", log); @@ -256,7 +256,7 @@ namespace argus { GLint uniform_count; glGetProgramiv(program_handle, GL_ACTIVE_UNIFORM_MAX_LENGTH, &uniform_max_len); - assert(uniform_max_len >= 0); + argus_assert(uniform_max_len >= 0); glGetProgramiv(program_handle, GL_ACTIVE_UNIFORMS, &uniform_count); GLsizei uniform_name_len; @@ -267,9 +267,9 @@ namespace argus { for (int i = 0; i < uniform_count; i++) { glGetActiveUniform(program_handle, uint32_t(i), uniform_max_len, &uniform_name_len, &uniform_size, &uniform_type, uniform_name); - assert(uniform_name_len <= uniform_max_len); + argus_assert(uniform_name_len <= uniform_max_len); GLint uniform_loc = glGetUniformLocation(program_handle, uniform_name); - assert(uniform_loc >= 0); + argus_assert(uniform_loc >= 0); refl_info.uniform_variable_locations[std::string(uniform_name)] = uint32_t(uniform_loc); } } diff --git a/engine/dynamic/render_vulkan/src/module_render_vulkan.cpp b/engine/dynamic/render_vulkan/src/module_render_vulkan.cpp index d3c2fe87..c5339c2f 100644 --- a/engine/dynamic/render_vulkan/src/module_render_vulkan.cpp +++ b/engine/dynamic/render_vulkan/src/module_render_vulkan.cpp @@ -220,7 +220,7 @@ namespace argus { } auto it = g_renderer_map.find(&window); - assert(it != g_renderer_map.end()); + argus_assert(it != g_renderer_map.end()); auto &renderer = it->second; if (!renderer->m_is_initted) { @@ -236,7 +236,7 @@ namespace argus { } auto it = g_renderer_map.find(&window); - assert(it != g_renderer_map.end()); + argus_assert(it != g_renderer_map.end()); it->second->notify_window_resize(event.resolution); break; diff --git a/engine/dynamic/render_vulkan/src/util/buffer.cpp b/engine/dynamic/render_vulkan/src/util/buffer.cpp index 357aaeed..1c14c7c7 100644 --- a/engine/dynamic/render_vulkan/src/util/buffer.cpp +++ b/engine/dynamic/render_vulkan/src/util/buffer.cpp @@ -34,7 +34,7 @@ namespace argus { BufferInfo alloc_buffer(const LogicalDevice &device, VkDeviceSize size, VkBufferUsageFlags usage, GraphicsMemoryPropCombos props) { - assert(size > 0); + argus_assert(size > 0); VkBufferCreateInfo buffer_info {}; buffer_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; @@ -72,8 +72,8 @@ namespace argus { } void free_buffer(BufferInfo &buffer) { - assert(buffer.device != VK_NULL_HANDLE); - assert(buffer.handle != VK_NULL_HANDLE); + argus_assert(buffer.device != VK_NULL_HANDLE); + argus_assert(buffer.handle != VK_NULL_HANDLE); if (buffer.mapped != nullptr) { unmap_buffer(buffer); @@ -87,10 +87,10 @@ namespace argus { void *map_buffer(BufferInfo &buffer, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags) { - assert(buffer.device != VK_NULL_HANDLE); - assert(buffer.handle != VK_NULL_HANDLE); - assert(size <= buffer.size); - assert(buffer.mapped == nullptr); + argus_assert(buffer.device != VK_NULL_HANDLE); + argus_assert(buffer.handle != VK_NULL_HANDLE); + argus_assert(size <= buffer.size); + argus_assert(buffer.mapped == nullptr); void *ptr; if (vkMapMemory(buffer.device, buffer.mem, offset, size, flags, &ptr) != VK_SUCCESS) { @@ -103,9 +103,9 @@ namespace argus { } void unmap_buffer(BufferInfo &buffer) { - assert(buffer.device != VK_NULL_HANDLE); - assert(buffer.handle != VK_NULL_HANDLE); - assert(buffer.mapped != nullptr); + argus_assert(buffer.device != VK_NULL_HANDLE); + argus_assert(buffer.handle != VK_NULL_HANDLE); + argus_assert(buffer.mapped != nullptr); vkUnmapMemory(buffer.device, buffer.mem); buffer.mapped = nullptr; @@ -113,10 +113,10 @@ namespace argus { void copy_buffer(const CommandBufferInfo &cmd_buf, const BufferInfo &src_buf, VkDeviceSize src_off, const BufferInfo &dst_buf, VkDeviceSize dst_off, size_t size) { - assert(src_buf.device != VK_NULL_HANDLE); - assert(src_buf.handle != VK_NULL_HANDLE); - assert(dst_buf.device != VK_NULL_HANDLE); - assert(dst_buf.handle != VK_NULL_HANDLE); + argus_assert(src_buf.device != VK_NULL_HANDLE); + argus_assert(src_buf.handle != VK_NULL_HANDLE); + argus_assert(dst_buf.device != VK_NULL_HANDLE); + argus_assert(dst_buf.handle != VK_NULL_HANDLE); VkBufferCopy copy_region {}; copy_region.srcOffset = src_off; diff --git a/engine/dynamic/render_vulkan/src/util/command_buffer.cpp b/engine/dynamic/render_vulkan/src/util/command_buffer.cpp index 82897501..62a13356 100644 --- a/engine/dynamic/render_vulkan/src/util/command_buffer.cpp +++ b/engine/dynamic/render_vulkan/src/util/command_buffer.cpp @@ -111,7 +111,7 @@ namespace argus { const std::vector &signal_semaphores) { UNUSED(device); - assert(wait_semaphores.size() == wait_stages.size()); + argus_assert(wait_semaphores.size() == wait_stages.size()); VkSubmitInfo submit_info {}; submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; diff --git a/engine/dynamic/render_vulkan/src/util/framebuffer.cpp b/engine/dynamic/render_vulkan/src/util/framebuffer.cpp index e7a271e5..762e596d 100644 --- a/engine/dynamic/render_vulkan/src/util/framebuffer.cpp +++ b/engine/dynamic/render_vulkan/src/util/framebuffer.cpp @@ -52,7 +52,7 @@ namespace argus { VkFramebuffer create_framebuffer(const LogicalDevice &device, VkRenderPass render_pass, const std::vector &images) { - assert(!images.empty()); + argus_assert(!images.empty()); std::vector image_views; image_views.resize(images.size()); diff --git a/engine/libs/lowlevel/include/argus/lowlevel/debug.hpp b/engine/libs/lowlevel/include/argus/lowlevel/debug.hpp index 89d6a7cd..6bad63ec 100644 --- a/engine/libs/lowlevel/include/argus/lowlevel/debug.hpp +++ b/engine/libs/lowlevel/include/argus/lowlevel/debug.hpp @@ -42,15 +42,15 @@ #define _argus_assert(cond, file, line) ((cond) \ ? void(0) \ : ::argus::crash("Assertion failed: " file ":" STRINGIZE(line) ": " #cond)) -#define assert(...) _argus_assert((__VA_ARGS__), __FILE__, __LINE__) +#define argus_assert(...) _argus_assert((__VA_ARGS__), __FILE__, __LINE__) #define _argus_assert_ll(cond, file, line) ((cond) \ ? void(0) \ : ::argus::crash_ll("Assertion failed: " file ":" STRINGIZE(line) ": " #cond)) -#define assert_ll(...) _argus_assert_ll((__VA_ARGS__), __FILE__, __LINE__) +#define argus_assert_ll(...) _argus_assert_ll((__VA_ARGS__), __FILE__, __LINE__) #else #define _argus_assert(cond) ((cond) ? (void(0)) : (argus::crash("Assertion failed: " #cond))) -#define assert(...) _argus_assert((__VA_ARGS__)) +#define argus_assert(...) _argus_assert((__VA_ARGS__)) #define _argus_assert_ll(cond) ((cond) ? (void(0)) : (argus::crash_ll("Assertion failed: " #cond))) -#define assert_ll(...) _argus_assert_ll((__VA_ARGS__)) +#define argus_assert_ll(...) _argus_assert_ll((__VA_ARGS__)) #endif diff --git a/engine/libs/lowlevel/include/argus/lowlevel/refcountable.hpp b/engine/libs/lowlevel/include/argus/lowlevel/refcountable.hpp index b91a7acc..787d4999 100644 --- a/engine/libs/lowlevel/include/argus/lowlevel/refcountable.hpp +++ b/engine/libs/lowlevel/include/argus/lowlevel/refcountable.hpp @@ -53,10 +53,10 @@ namespace argus { size_t release(uint32_t release_count = 1) { if constexpr (Atomic) { auto prev_val = refcount.fetch_sub(release_count); - assert_ll(release_count <= prev_val); + argus_assert_ll(release_count <= prev_val); return prev_val - release_count; } else { - assert_ll(release_count <= refcount); + argus_assert_ll(release_count <= refcount); refcount -= release_count; return refcount; } diff --git a/engine/libs/lowlevel/src/color.cpp b/engine/libs/lowlevel/src/color.cpp index 53bad823..7ad89923 100644 --- a/engine/libs/lowlevel/src/color.cpp +++ b/engine/libs/lowlevel/src/color.cpp @@ -77,7 +77,7 @@ namespace argus { double g; double b; - assert_ll(hprime >= -1); + argus_assert_ll(hprime >= -1); if (hprime < 0) { r = max; g = min; diff --git a/engine/libs/lowlevel/src/filesystem.cpp b/engine/libs/lowlevel/src/filesystem.cpp index fbb3216f..c7a7742e 100644 --- a/engine/libs/lowlevel/src/filesystem.cpp +++ b/engine/libs/lowlevel/src/filesystem.cpp @@ -200,7 +200,7 @@ namespace argus { return err(_map_file_error(errno), errno); } - assert(stat_buf.st_size >= 0); + argus_assert(stat_buf.st_size >= 0); return ok( FileHandle(path, mode, size_t(stat_buf.st_size), static_cast(file))); @@ -292,7 +292,7 @@ namespace argus { return err(errno); } - assert(file_stat.st_size >= 0); + argus_assert(file_stat.st_size >= 0); this->m_size = size_t(file_stat.st_size); diff --git a/engine/static/core/include/argus/core/event.hpp b/engine/static/core/include/argus/core/event.hpp index bc57cfd6..63627ffc 100644 --- a/engine/static/core/include/argus/core/event.hpp +++ b/engine/static/core/include/argus/core/event.hpp @@ -119,7 +119,7 @@ namespace argus { return register_event_handler_with_type(EventType::get_event_type_id(), [callback = std::move(callback)](const ArgusEvent &e, void *d) { UNUSED(d); - assert(e.type_id == EventType::get_event_type_id()); + argus_assert(e.type_id == EventType::get_event_type_id()); callback(reinterpret_cast(e)); }, target_thread, nullptr, ordering, nullptr); @@ -147,7 +147,7 @@ namespace argus { "Event class must contain static function get_event_type_id"); return register_event_handler_with_type(EventType::get_event_type_id(), [callback = std::move(callback)](const ArgusEvent &e, void *d) { - assert(e.type_id == EventType::get_event_type_id()); + argus_assert(e.type_id == EventType::get_event_type_id()); callback(reinterpret_cast(e), d); }, target_thread, data, ordering, nullptr); diff --git a/engine/static/core/src/cabi/engine.cpp b/engine/static/core/src/cabi/engine.cpp index 9a9981a2..a797ce1c 100644 --- a/engine/static/core/src/cabi/engine.cpp +++ b/engine/static/core/src/cabi/engine.cpp @@ -24,7 +24,7 @@ static argus::DeltaCallback _wrap_delta_callback(delta_callback_t callback) { return [callback](auto dur) { - assert(dur.count() >= 0); + argus_assert(dur.count() >= 0); callback(uint64_t(dur.count())); }; } diff --git a/engine/static/core/src/client_config.cpp b/engine/static/core/src/client_config.cpp index d8305da8..a563165a 100644 --- a/engine/static/core/src/client_config.cpp +++ b/engine/static/core/src/client_config.cpp @@ -386,7 +386,7 @@ namespace argus { continue; } - assert(rc == 0); + argus_assert(rc == 0); auto *res = arp_load_resource(&res_meta); if (res == nullptr) { diff --git a/engine/static/core/src/event.cpp b/engine/static/core/src/event.cpp index 51c37978..7774ec5d 100644 --- a/engine/static/core/src/event.cpp +++ b/engine/static/core/src/event.cpp @@ -48,7 +48,7 @@ namespace argus { static std::mutex g_render_event_queue_mutex; void process_event_queue(TargetThread target_thread) { - assert(target_thread == TargetThread::Update || target_thread == TargetThread::Render); + argus_assert(target_thread == TargetThread::Update || target_thread == TargetThread::Render); auto render_thread = target_thread == TargetThread::Render; diff --git a/engine/static/ecs/src/entity.cpp b/engine/static/ecs/src/entity.cpp index b888506a..77b444c8 100644 --- a/engine/static/ecs/src/entity.cpp +++ b/engine/static/ecs/src/entity.cpp @@ -76,7 +76,7 @@ namespace argus { } void Entity::destroy(void) { - assert(ComponentTypeRegistry::instance().get_type_count() < UINT16_MAX); + argus_assert(ComponentTypeRegistry::instance().get_type_count() < UINT16_MAX); for (ComponentTypeId cmp_id = 0; cmp_id < uint16_t(ComponentTypeRegistry::instance().get_type_count()); cmp_id++) { diff --git a/engine/static/input/src/gamepad.cpp b/engine/static/input/src/gamepad.cpp index d3036caa..73f359ff 100644 --- a/engine/static/input/src/gamepad.cpp +++ b/engine/static/input/src/gamepad.cpp @@ -169,7 +169,7 @@ namespace argus::input { return false; } - assert(sdl_button_it->second >= 0); + argus_assert(sdl_button_it->second >= 0); std::lock_guard lock(InputManager::instance().m_pimpl->gamepad_states_mutex); @@ -200,7 +200,7 @@ namespace argus::input { } auto axis_state = it->second.axis_state; - assert(size_t(axis) < axis_state.size()); + argus_assert(size_t(axis) < axis_state.size()); return axis_state[size_t(axis)]; } @@ -221,7 +221,7 @@ namespace argus::input { } auto deltas = it->second.axis_deltas; - assert(size_t(axis) < deltas.size()); + argus_assert(size_t(axis) < deltas.size()); return deltas[size_t(axis)]; } @@ -355,7 +355,7 @@ namespace argus::input { auto d_deadzone_to_point = d_center - r_deadzone; auto d_deadzone_to_boundary = d_boundary - r_deadzone; - assert(d_deadzone_to_boundary > 0.0); + argus_assert(d_deadzone_to_boundary > 0.0); new_x = x * (d_deadzone_to_point / d_deadzone_to_boundary); new_y = y * (d_deadzone_to_point / d_deadzone_to_boundary); } @@ -367,8 +367,8 @@ namespace argus::input { new_x = 0; new_y = 0; } else { - assert(radius_x < 1.0); - assert(radius_y < 1.0); + argus_assert(radius_x < 1.0); + argus_assert(radius_y < 1.0); auto r = std::max(std::abs(x), std::abs(y)); new_x = x * (r - radius_x) / (1.0 - radius_x); new_y = y * (r - radius_y) / (1.0 - radius_y); @@ -379,13 +379,13 @@ namespace argus::input { if (std::abs(x) < radius_x) { new_x = 0; } else { - assert(radius_x < 1.0); + argus_assert(radius_x < 1.0); new_x = x * (std::abs(x) - radius_x) / (1.0 - radius_x); } if (std::abs(y) < radius_y) { new_y = 0; } else { - assert(radius_y < 1.0); + argus_assert(radius_y < 1.0); new_y = y * (std::abs(y) - radius_y) / (1.0 - radius_y); } break; diff --git a/engine/static/scripting/include/argus/scripting/bind.hpp b/engine/static/scripting/include/argus/scripting/bind.hpp index e7bb891a..154fd13b 100644 --- a/engine/static/scripting/include/argus/scripting/bind.hpp +++ b/engine/static/scripting/include/argus/scripting/bind.hpp @@ -415,7 +415,7 @@ namespace argus { && !std::is_same_v && !is_std_vector_v && !is_std_function_v) { - assert(real_type.type == IntegralType::Struct); + argus_assert(real_type.type == IntegralType::Struct); if constexpr (std::is_base_of_v) { // return a pointer to the field so the script can modify its fields real_type.type = IntegralType::Pointer; diff --git a/engine/static/scripting/include/argus/scripting/types.hpp b/engine/static/scripting/include/argus/scripting/types.hpp index 6664f33c..308e5a7f 100644 --- a/engine/static/scripting/include/argus/scripting/types.hpp +++ b/engine/static/scripting/include/argus/scripting/types.hpp @@ -304,7 +304,7 @@ namespace argus { if (!(type.type == IntegralType::String || type.type == IntegralType::Pointer || type.type == IntegralType::Vector || type.type == IntegralType::VectorRef)) { - assert(type.size == sizeof(T)); + argus_assert(type.size == sizeof(T)); } switch (type.type) { @@ -312,50 +312,50 @@ namespace argus { crash("Cannot get void value from ObjectWrapper"); } case IntegralType::Integer: { - assert(std::is_integral_v); + argus_assert(std::is_integral_v); break; } case IntegralType::Float: { - assert(std::is_floating_point_v); + argus_assert(std::is_floating_point_v); break; } case IntegralType::Boolean: { - assert(std::is_integral_v); + argus_assert(std::is_integral_v); break; } case IntegralType::String: { - assert(false); + argus_assert(false); } case IntegralType::Struct: { - assert(type.type_index.value() == typeid(T)); + argus_assert(type.type_index.value() == typeid(T)); break; } case IntegralType::Pointer: { - assert(type.type_index.value() == typeid(std::remove_pointer_t)); + argus_assert(type.type_index.value() == typeid(std::remove_pointer_t)); break; } case IntegralType::Enum: { if constexpr (std::is_enum_v) { - assert(type.type_index.value() == typeid(T)); + argus_assert(type.type_index.value() == typeid(T)); } else { - assert(std::is_integral_v); + argus_assert(std::is_integral_v); } break; } case IntegralType::Callback: { - assert(std::is_same_v || std::is_same_v); + argus_assert(std::is_same_v || std::is_same_v); break; } case IntegralType::Type: { - assert(std::is_same_v); + argus_assert(std::is_same_v); break; } case IntegralType::Vector: { - assert(std::is_same_v); + argus_assert(std::is_same_v); break; } case IntegralType::VectorRef: { - assert(std::is_same_v); + argus_assert(std::is_same_v); break; } default: { @@ -398,7 +398,7 @@ namespace argus { template T &get_value(void) { static_assert(!is_reference_wrapper_v, "Use lvalue reference instead of reference_wrapper"); - assert(is_initialized); + argus_assert(is_initialized); if constexpr (std::is_pointer_v && std::is_same_v>, char>) { return reinterpret_cast(get_ptr0()); @@ -406,7 +406,7 @@ namespace argus { _validate_value_type(type); if (type.type == IntegralType::Pointer) { - assert(type.type_index.value() == typeid(std::remove_pointer_t)); + argus_assert(type.type_index.value() == typeid(std::remove_pointer_t)); return **reinterpret_cast **>(get_ptr0()); } else { return *reinterpret_cast *>(get_ptr0()); @@ -416,15 +416,15 @@ namespace argus { template const T &get_value(void) const { - assert(is_initialized); + argus_assert(is_initialized); return reinterpret_cast(get_value()); } template void store_value(T val) { - assert(!is_initialized); - assert(this->buffer_size == sizeof(T)); + argus_assert(!is_initialized); + argus_assert(this->buffer_size == sizeof(T)); _validate_value_type(type); *reinterpret_cast(get_ptr0()) = val; @@ -433,7 +433,7 @@ namespace argus { template T &emplace(Args... args) { - assert(!is_initialized); + argus_assert(!is_initialized); _validate_value_type(type); new(get_ptr0()) T(args...); diff --git a/engine/static/scripting/include/argus/scripting/wrapper.hpp b/engine/static/scripting/include/argus/scripting/wrapper.hpp index ee90333f..bfbd0333 100644 --- a/engine/static/scripting/include/argus/scripting/wrapper.hpp +++ b/engine/static/scripting/include/argus/scripting/wrapper.hpp @@ -82,7 +82,7 @@ namespace argus { static_assert(!std::is_same_v, "Vectors of booleans are not supported"); static_assert(!std::is_same_v>, char *>, "Vectors of C-strings are not supported (use std::string instead)"); - assert(type.element_type.has_value()); + argus_assert(type.element_type.has_value()); // ensure the vector reference will remain valid if (type.type == IntegralType::VectorRef && is_heap) { @@ -90,7 +90,7 @@ namespace argus { VectorWrapper(const_cast &>(vec), *type.element_type.value())); } else { if (type.element_type.value()->type != IntegralType::String) { - assert(type.element_type.value()->size == sizeof(E)); + argus_assert(type.element_type.value()->size == sizeof(E)); } ObjectType real_type = type; @@ -186,11 +186,11 @@ namespace argus { static T unwrap_param(ObjectWrapper ¶m, ScratchAllocator *scratch) { using B = std::remove_const_t>; - assert(param.is_initialized); + argus_assert(param.is_initialized); if constexpr (is_std_function_v) { - assert(param.type.type == IntegralType::Callback); - assert(param.type.callback_type.has_value()); + argus_assert(param.type.type == IntegralType::Callback); + argus_assert(param.type.callback_type.has_value()); using ReturnType = typename function_traits::return_type; using ArgsTuple = typename function_traits::argument_types_wrapped; @@ -202,11 +202,11 @@ namespace argus { for (auto &subparam : param_types) { if (subparam.type == IntegralType::Pointer || subparam.type == IntegralType::Struct) { - assert(subparam.type_index.has_value()); + argus_assert(subparam.type_index.has_value()); subparam.type_name = get_bound_type(subparam.type_index.value()) .expect("Tried to unwrap callback param with unbound struct type").name; } else if (subparam.type == IntegralType::Enum) { - assert(subparam.type_index.has_value()); + argus_assert(subparam.type_index.has_value()); subparam.type_name = get_bound_enum(subparam.type_index.value()) .expect("Tried to unwrap callback param with unbound enum type").name; } @@ -246,7 +246,7 @@ namespace argus { } }; } else if constexpr (std::is_same_v) { - assert(param.type.type == IntegralType::String); + argus_assert(param.type.type == IntegralType::String); if constexpr (std::is_same_v, std::string>) { if (scratch != nullptr) { @@ -256,13 +256,13 @@ namespace argus { return str; } } else { - assert(scratch != nullptr); + argus_assert(scratch != nullptr); std::string &str = scratch->construct(reinterpret_cast(param.get_ptr0())); return str; } } else if constexpr (std::is_same_v>, std::string>) { - assert(param.type.type == IntegralType::String); - assert(scratch != nullptr); + argus_assert(param.type.type == IntegralType::String); + argus_assert(scratch != nullptr); std::string *str = &scratch->construct(reinterpret_cast(param.get_ptr0())); return str; } else if constexpr (is_std_vector_v>>) { @@ -295,14 +295,14 @@ namespace argus { crash("Invalid vector object type magic"); } } else if constexpr (is_reference_wrapper_v) { - assert(param.type.type == IntegralType::Pointer); + argus_assert(param.type.type == IntegralType::Pointer); if constexpr (std::is_same_v) { return std::ref(param.get_value()); } else { return param.get_value>>(); } } else if constexpr (std::is_pointer_v>) { - assert(param.type.type == IntegralType::Pointer); + argus_assert(param.type.type == IntegralType::Pointer); if constexpr (std::is_same_v) { return param.get_value(); } else { diff --git a/engine/static/scripting/src/bind.cpp b/engine/static/scripting/src/bind.cpp index e48aa6c2..2a760b35 100644 --- a/engine/static/scripting/src/bind.cpp +++ b/engine/static/scripting/src/bind.cpp @@ -38,7 +38,7 @@ namespace argus { [[nodiscard]] static Result _resolve_param(ObjectType ¶m_def, bool check_copyable = true) { if (param_def.type == IntegralType::Callback) { - assert(param_def.callback_type.has_value()); + argus_assert(param_def.callback_type.has_value()); auto &callback_type = *param_def.callback_type.value(); for (auto &subparam : callback_type.params) { auto sub_res = _resolve_param(subparam); @@ -54,7 +54,7 @@ namespace argus { return ok(); } else if (param_def.type == IntegralType::Vector || param_def.type == IntegralType::VectorRef) { - assert(param_def.element_type.has_value()); + argus_assert(param_def.element_type.has_value()); auto el_res = _resolve_param(*param_def.element_type.value(), false); if (el_res.is_err()) { return el_res; @@ -65,8 +65,8 @@ namespace argus { return ok(); } - assert(param_def.type_index.has_value()); - assert(!param_def.type_name.has_value()); + argus_assert(param_def.type_index.has_value()); + argus_assert(!param_def.type_name.has_value()); std::string type_name; if (param_def.type == IntegralType::Enum) { @@ -117,7 +117,7 @@ namespace argus { [[nodiscard]] static Result _resolve_field(ObjectType &field_def) { if (field_def.type == IntegralType::Vector || field_def.type == IntegralType::VectorRef) { - assert(field_def.element_type.has_value()); + argus_assert(field_def.element_type.has_value()); auto el_res = _resolve_field(*field_def.element_type.value()); if (el_res.is_err()) { return el_res; @@ -128,8 +128,8 @@ namespace argus { return ok(); } - assert(field_def.type_index.has_value()); - assert(!field_def.type_name.has_value()); + argus_assert(field_def.type_index.has_value()); + argus_assert(!field_def.type_name.has_value()); std::string type_name; if (field_def.type == IntegralType::Enum) { @@ -263,7 +263,7 @@ namespace argus { " is called after creating type definition)"); } auto type_it = g_bound_types.find(index_it->second); - assert(type_it != g_bound_types.cend()); + argus_assert(type_it != g_bound_types.cend()); return ok(const_cast(type_it->second)); } @@ -276,7 +276,7 @@ namespace argus { "is called after creating type definition)"); } auto enum_it = g_bound_enums.find(index_it->second); - assert(enum_it != g_bound_enums.cend()); + argus_assert(enum_it != g_bound_enums.cend()); return ok(const_cast(enum_it->second)); } diff --git a/engine/static/scripting/src/bridge.cpp b/engine/static/scripting/src/bridge.cpp index bba9bacc..c77566c5 100644 --- a/engine/static/scripting/src/bridge.cpp +++ b/engine/static/scripting/src/bridge.cpp @@ -120,7 +120,7 @@ namespace argus { return err("Too many arguments provided"); } - assert(params.size() == expected_param_count); + argus_assert(params.size() == expected_param_count); return def.handle(params); } diff --git a/engine/static/scripting/src/handles.cpp b/engine/static/scripting/src/handles.cpp index 4c554515..8a6b41a3 100644 --- a/engine/static/scripting/src/handles.cpp +++ b/engine/static/scripting/src/handles.cpp @@ -39,7 +39,7 @@ namespace argus { ScriptBindableHandle get_or_create_sv_handle(void *ptr, const std::type_index &type) { auto handle_it = g_ptr_to_handle_map.find(ptr); if (handle_it != g_ptr_to_handle_map.cend()) { - assert(handle_it->second.first == type); + argus_assert(handle_it->second.first == type); return handle_it->second.second; } else { if (g_next_handle == k_handle_max) { diff --git a/engine/static/scripting/src/types.cpp b/engine/static/scripting/src/types.cpp index 62ec9430..49bfd8ef 100644 --- a/engine/static/scripting/src/types.cpp +++ b/engine/static/scripting/src/types.cpp @@ -116,7 +116,7 @@ namespace argus { ObjectWrapper::ObjectWrapper(const ObjectType &type, size_t size): type(type), is_initialized(false) { - assert(type.type == IntegralType::String || type.type == IntegralType::Pointer + argus_assert(type.type == IntegralType::String || type.type == IntegralType::Pointer || type.type == IntegralType::Vector || type.type == IntegralType::VectorRef || type.size == size); // override size for pointer type since we're only copying the pointer @@ -183,15 +183,15 @@ namespace argus { } void ObjectWrapper::copy_value_from(const void *src, size_t size) { - assert(size == this->buffer_size); + argus_assert(size == this->buffer_size); copy_wrapped_object(this->type, this->get_ptr0(), src, size); this->is_initialized = true; } // this function is only used with struct value types void ObjectWrapper::copy_value_into(void *dest, size_t size) const { - assert(size == this->buffer_size); - assert(this->is_initialized); + argus_assert(size == this->buffer_size); + argus_assert(this->is_initialized); copy_wrapped_object(this->type, dest, this->get_ptr0(), size); } @@ -200,7 +200,7 @@ namespace argus { } void BoundFieldDef::set_value(ObjectWrapper &instance, ObjectWrapper &value) const { - assert(m_assign_proxy.has_value()); + argus_assert(m_assign_proxy.has_value()); m_assign_proxy.value()(instance, value); } diff --git a/engine/static/scripting/src/wrapper.cpp b/engine/static/scripting/src/wrapper.cpp index c53d9153..0bc8b3a0 100644 --- a/engine/static/scripting/src/wrapper.cpp +++ b/engine/static/scripting/src/wrapper.cpp @@ -47,10 +47,10 @@ namespace argus { Result create_int_object_wrapper(const ObjectType &type, int64_t val) { ObjectWrapper wrapper(type, type.size); - assert(wrapper.buffer_size >= type.size); + argus_assert(wrapper.buffer_size >= type.size); if (type.type == IntegralType::Enum) { - assert(type.type_name.has_value()); + argus_assert(type.type_name.has_value()); auto enum_def = get_bound_enum(type.type_name.value()) .expect("Tried to create ObjectWrapper with unbound enum type"); auto enum_val_it = enum_def.all_ordinals.find(*reinterpret_cast(&val)); @@ -78,7 +78,7 @@ namespace argus { break; } default: - assert(false); // should have been caught during binding + argus_assert(false); // should have been caught during binding } return ok(std::move(wrapper)); @@ -97,14 +97,14 @@ namespace argus { break; } default: - assert(false); // should have been caught during binding + argus_assert(false); // should have been caught during binding } return ok(std::move(wrapper)); } Result create_bool_object_wrapper(const ObjectType &type, bool val) { - assert(type.size >= sizeof(bool)); + argus_assert(type.size >= sizeof(bool)); ObjectWrapper wrapper(type, type.size); @@ -185,7 +185,7 @@ namespace argus { // can just copy the whole thing in one go and avoid looping memcpy(blob[0], data, el_size * count); } else { - assert(count < SIZE_MAX); + argus_assert(count < SIZE_MAX); if (el_type.type == IntegralType::String) { // strings need to be handled specially because they're the only @@ -202,12 +202,12 @@ namespace argus { new(dst_ptr) std::string(src_str); } } else { - assert(el_type.type == IntegralType::Struct); + argus_assert(el_type.type == IntegralType::Struct); auto bound_type_res = get_bound_type(el_type.type_index.value()); const BoundTypeDef &bound_type = bound_type_res .expect("Tried to create ObjectWrapper with unbound struct type"); - assert(bound_type.copy_ctor != nullptr); + argus_assert(bound_type.copy_ctor != nullptr); for (size_t i = 0; i < count; i++) { void *src_ptr = reinterpret_cast( @@ -266,12 +266,12 @@ namespace argus { // can just copy the whole thing in one go and avoid looping memcpy(new_blob.data(), src.data(), el_size * count); } else { - assert(count < SIZE_MAX); + argus_assert(count < SIZE_MAX); auto bound_type_res = get_bound_type(el_type.type_index.value()); const BoundTypeDef &bound_type = bound_type_res .expect("Tried to copy/move ArrayBlob with unbound element type"); - assert(bound_type.copy_ctor != nullptr); + argus_assert(bound_type.copy_ctor != nullptr); for (size_t i = 0; i < count; i++) { std::conditional_t src_ptr = src[i]; @@ -288,7 +288,7 @@ namespace argus { template> static void _copy_or_move_type(void *dst, SrcPtr src, size_t max_len) { - assert(max_len >= sizeof(T)); + argus_assert(max_len >= sizeof(T)); if constexpr (is_move) { new(dst) T(std::move(*reinterpret_cast(src))); } else { @@ -317,15 +317,15 @@ namespace argus { // for complex value types we indirectly use the copy/move // constructors - assert(obj_type.type_index.has_value()); + argus_assert(obj_type.type_index.has_value()); auto bound_type = get_bound_type(obj_type.type_index.value()) .expect("Tried to copy/move wrapped object with unbound struct type"); if constexpr (is_move) { - assert(bound_type.move_ctor != nullptr); + argus_assert(bound_type.move_ctor != nullptr); bound_type.move_ctor(dst, src); } else { - assert(bound_type.copy_ctor != nullptr); + argus_assert(bound_type.copy_ctor != nullptr); bound_type.copy_ctor(dst, src); } @@ -385,11 +385,11 @@ namespace argus { // for complex value types we indirectly use the copy/move // constructors - assert(obj_type.type_index.has_value()); + argus_assert(obj_type.type_index.has_value()); auto bound_type = get_bound_type(obj_type.type_index.value()) .expect("Tried to destruct wrapped object with unbound struct type"); - assert(bound_type.dtor != nullptr); + argus_assert(bound_type.dtor != nullptr); bound_type.dtor(ptr); break; diff --git a/engine/static/scripting_lua/src/lua_language_plugin.cpp b/engine/static/scripting_lua/src/lua_language_plugin.cpp index 3efbbc80..8ba7126f 100644 --- a/engine/static/scripting_lua/src/lua_language_plugin.cpp +++ b/engine/static/scripting_lua/src/lua_language_plugin.cpp @@ -79,7 +79,7 @@ namespace argus { ~StackGuard(void) { int cur = lua_gettop(m_state); if (cur != m_expected) { - assert(lua_gettop(m_state) == m_expected); + argus_assert(lua_gettop(m_state) == m_expected); } } @@ -92,7 +92,7 @@ namespace argus { } void decrement(int count) { - assert(count <= m_expected); + argus_assert(count <= m_expected); increment(-count); } @@ -387,7 +387,7 @@ namespace argus { if (element_type.type == IntegralType::Pointer) { blob.set(i, ptr); } else { - assert(element_type.type == IntegralType::Struct); + argus_assert(element_type.type == IntegralType::Struct); if (bound_type.copy_ctor != nullptr) { bound_type.copy_ctor(blob[i], ptr); @@ -463,8 +463,8 @@ namespace argus { } case IntegralType::Struct: case IntegralType::Pointer: { - assert(param_def.type_name.has_value()); - assert(param_def.type_index.has_value()); + argus_assert(param_def.type_name.has_value()); + argus_assert(param_def.type_index.has_value()); if (!lua_isuserdata(state, param_index)) { return err("Incorrect type provided for parameter " @@ -562,7 +562,7 @@ namespace argus { } case IntegralType::Vector: case IntegralType::VectorRef: { - assert(param_def.element_type.has_value()); + argus_assert(param_def.element_type.has_value()); if (lua_istable(state, param_index)) { return _read_vector_from_table(state, qual_fn_name, param_index, param_def); @@ -601,7 +601,7 @@ namespace argus { } static int64_t _unwrap_int_wrapper(const ObjectWrapper &wrapper) { - assert(wrapper.type.type == IntegralType::Integer + argus_assert(wrapper.type.type == IntegralType::Integer || wrapper.type.type == IntegralType::Enum); switch (wrapper.type.size) { @@ -620,7 +620,7 @@ namespace argus { } static double _unwrap_float_wrapper(const ObjectWrapper &wrapper) { - assert(wrapper.type.type == IntegralType::Float); + argus_assert(wrapper.type.type == IntegralType::Float); switch (wrapper.type.size) { case 4: @@ -634,7 +634,7 @@ namespace argus { } static bool _unwrap_boolean_wrapper(const ObjectWrapper &wrapper) { - assert(wrapper.type.type == IntegralType::Boolean); + argus_assert(wrapper.type.type == IntegralType::Boolean); return *reinterpret_cast(wrapper.value); } @@ -643,7 +643,7 @@ namespace argus { auto mt = luaL_getmetatable(state, ((type.is_const ? k_const_prefix : "") + type.type_name.value()).c_str()); UNUSED(mt); - assert(mt != 0); // binding should have failed if type wasn't bound + argus_assert(mt != 0); // binding should have failed if type wasn't bound lua_setmetatable(state, -2); } @@ -703,7 +703,7 @@ namespace argus { } static void _push_vector_vals(lua_State *state, const ObjectType &element_type, const ArrayBlob &vec) { - assert(vec.size() < INT_MAX); + argus_assert(vec.size() < INT_MAX); for (size_t i = 0; i < vec.size(); i++) { // push index to stack lua_pushinteger(state, int(i + 1)); @@ -737,7 +737,7 @@ namespace argus { lua_pushstring(state, vec.at(i).c_str()); break; case IntegralType::Struct: { - assert(element_type.type_name.has_value()); + argus_assert(element_type.type_name.has_value()); auto *udata = reinterpret_cast(lua_newuserdata(state, sizeof(UserData) + element_type.size)); @@ -783,7 +783,7 @@ namespace argus { } static void _push_value(lua_State *state, const ObjectWrapper &wrapper) { - assert(wrapper.type.type != IntegralType::Void); + argus_assert(wrapper.type.type != IntegralType::Void); switch (wrapper.type.type) { case IntegralType::Integer: @@ -801,7 +801,7 @@ namespace argus { wrapper.is_on_heap ? wrapper.heap_ptr : wrapper.value)); break; case IntegralType::Struct: { - assert(wrapper.type.type_name.has_value()); + argus_assert(wrapper.type.type_name.has_value()); auto *udata = reinterpret_cast(lua_newuserdata(state, sizeof(UserData) + wrapper.type.size)); @@ -812,8 +812,8 @@ namespace argus { break; } case IntegralType::Pointer: { - assert(wrapper.type.type_name.has_value()); - assert(wrapper.type.type_index.has_value()); + argus_assert(wrapper.type.type_name.has_value()); + argus_assert(wrapper.type.type_index.has_value()); void *ptr = *reinterpret_cast(wrapper.get_ptr0()); @@ -837,7 +837,7 @@ namespace argus { // create table to return lua_createtable(state, int(vec.size()), 0); - assert(wrapper.type.element_type.has_value()); + argus_assert(wrapper.type.element_type.has_value()); _push_vector_vals(state, *wrapper.type.element_type.value(), vec); // create metatable @@ -878,7 +878,7 @@ namespace argus { break; } default: - assert(false); + argus_assert(false); } } @@ -1096,7 +1096,7 @@ namespace argus { std::string type_name = _get_metatable_name(state, 1); std::string key = lua_tostring(state, -1); - assert(!type_name.empty()); + argus_assert(!type_name.empty()); if (_get_native_field_val(state, type_name, key)) { stack_guard.increment(); @@ -1153,7 +1153,7 @@ namespace argus { return _set_lua_error(state, val_wrapper_res.unwrap_err()); } - assert(field.m_assign_proxy.has_value()); + argus_assert(field.m_assign_proxy.has_value()); field.m_assign_proxy.value()(inst_wrapper, val_wrapper_res.unwrap()); return 0; @@ -1165,7 +1165,7 @@ namespace argus { std::string type_name = _get_metatable_name(state, 1); std::string key = lua_tostring(state, -2); - assert(!type_name.empty()); + argus_assert(!type_name.empty()); auto res = _set_native_field(state, type_name, key); @@ -1216,7 +1216,7 @@ namespace argus { stack_guard.increment(); auto mt = luaL_getmetatable(state, type_def.name.c_str()); UNUSED(mt); - assert(mt != 0); // binding should have failed if type wasn't bound + argus_assert(mt != 0); // binding should have failed if type wasn't bound lua_setmetatable(state, -2); type_def.copy_ctor(dest->data, src); @@ -1314,7 +1314,7 @@ namespace argus { } static void _bind_global_fn(lua_State *state, const BoundFunctionDef &fn) { - assert(fn.type == FunctionType::Global); + argus_assert(fn.type == FunctionType::Global); // put the namespace table on the stack luaL_getmetatable(state, k_engine_namespace); @@ -1462,7 +1462,7 @@ namespace argus { } Result LuaLanguagePlugin::load_script(ScriptContext &context, const Resource &resource) { - assert(resource.prototype.media_type == k_resource_type_lua); + argus_assert(resource.prototype.media_type == k_resource_type_lua); auto *plugin_data = context.get_plugin_data(); auto &state = plugin_data->m_state; diff --git a/engine/static/wm/src/window.cpp b/engine/static/wm/src/window.cpp index 4382db6e..0eb59be5 100644 --- a/engine/static/wm/src/window.cpp +++ b/engine/static/wm/src/window.cpp @@ -459,8 +459,8 @@ namespace argus { if (custom_display_mode) { SDL_DisplayMode cur_mode = unwrap_display_mode(display_mode); SDL_GetClosestDisplayMode(target_display.m_pimpl->index, &cur_mode, &sdl_mode); - assert(sdl_mode.w > 0); - assert(sdl_mode.h > 0); + argus_assert(sdl_mode.w > 0); + argus_assert(sdl_mode.h > 0); SDL_SetWindowDisplayMode(m_pimpl->handle, &sdl_mode); } else { SDL_GetDesktopDisplayMode(target_display.m_pimpl->index, &sdl_mode);