From 4a07ab392fd5d1361bbd9b7c409a29e7525b718a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Sat, 20 Apr 2019 21:04:36 -0700 Subject: [PATCH] Cleanup. --- scripts/bgfx-codegen.lua | 30 ++++++++++++++++-------------- scripts/idl.lua | 28 ++++++++++++++-------------- scripts/temp.bgfx.idl.inl | 38 ++++++++++++++++++++++++++++++++++++++ src/bgfx.cpp | 36 ------------------------------------ src/bgfx.idl.inl | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+), 64 deletions(-) diff --git a/scripts/bgfx-codegen.lua b/scripts/bgfx-codegen.lua index 11bc96b95..ed2cfbbec 100644 --- a/scripts/bgfx-codegen.lua +++ b/scripts/bgfx-codegen.lua @@ -6,25 +6,27 @@ local codegen = require "codegen" local doxygen = require "doxygen" local func_actions = { - c99 = "\n", - c99decl = "\n", - cppdecl = "\n", + + c99 = "\n", + c99decl = "\n", + cppdecl = "\n", interface_struct = "\n\t", interface_import = ",\n\t\t\t", - c99_interface = "\n", - cpp_interface = "\n", - c99_functionid = "\n\t", - cpp_functionid = "\n\t\t", + c99_interface = "\n", + cpp_interface = "\n", + c99_functionid = "\n\t", + cpp_functionid = "\n\t\t", } local type_actions = { - enums = "\n", - cenums = "\n", - structs = "\n", - cstructs = "\n", - handles = "\n", - chandles = "\n", - funcptrs = "\n", + + enums = "\n", + cenums = "\n", + structs = "\n", + cstructs = "\n", + handles = "\n", + chandles = "\n", + funcptrs = "\n", cfuncptrs = "\n", } diff --git a/scripts/idl.lua b/scripts/idl.lua index 5c7d6e724..536e2a986 100644 --- a/scripts/idl.lua +++ b/scripts/idl.lua @@ -217,24 +217,24 @@ local function func(sets) end idl.funcptr = setmetatable({}, { __index = func(all_types) }) -idl.func = setmetatable({}, { __index = func(all_funcs) }) -idl.funcs = all_funcs +idl.func = setmetatable({}, { __index = func(all_funcs) }) +idl.funcs = all_funcs -idl.vararg = "vararg" -idl.out = "out" -idl.inout = "inout" -idl.const = "const" -idl.ctor = "ctor" -idl.cfunc = "cfunc" +idl.vararg = "vararg" +idl.out = "out" +idl.inout = "inout" +idl.const = "const" +idl.ctor = "ctor" +idl.cfunc = "cfunc" idl.underscore = "underscore" -idl.conly = "conly" -idl.cpponly = "cpponly" -idl.shortname = "shortname" -idl.NULL = "NULL" +idl.conly = "conly" +idl.cpponly = "cpponly" +idl.shortname = "shortname" +idl.NULL = "NULL" idl.UINT16_MAX = "UINT16_MAX" -idl.INT32_MAX = "INT32_MAX" +idl.INT32_MAX = "INT32_MAX" idl.UINT32_MAX = "UINT32_MAX" -idl.UINT8_MAX = "UINT8_MAX" +idl.UINT8_MAX = "UINT8_MAX" return setmetatable(idl , { __index = function (_, keyword) error (tostring(keyword) .. " is invalid") diff --git a/scripts/temp.bgfx.idl.inl b/scripts/temp.bgfx.idl.inl index 92652d751..d86172597 100644 --- a/scripts/temp.bgfx.idl.inl +++ b/scripts/temp.bgfx.idl.inl @@ -8,6 +8,44 @@ * */ +#define BGFX_C99_ENUM_CHECK(_enum, _c99enumcount) \ + BX_STATIC_ASSERT(_enum::Count == _enum::Enum(_c99enumcount) ) + +BGFX_C99_ENUM_CHECK(bgfx::Fatal, BGFX_FATAL_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::RendererType, BGFX_RENDERER_TYPE_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::Attrib, BGFX_ATTRIB_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::AttribType, BGFX_ATTRIB_TYPE_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::TextureFormat, BGFX_TEXTURE_FORMAT_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::UniformType, BGFX_UNIFORM_TYPE_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::BackbufferRatio, BGFX_BACKBUFFER_RATIO_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::OcclusionQueryResult, BGFX_OCCLUSION_QUERY_RESULT_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::Topology, BGFX_TOPOLOGY_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::TopologyConvert, BGFX_TOPOLOGY_CONVERT_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::RenderFrame, BGFX_RENDER_FRAME_COUNT); + +#undef BGFX_C99_ENUM_CHECK + +#define BGFX_C99_STRUCT_SIZE_CHECK(_cppstruct, _c99struct) \ + BX_STATIC_ASSERT(sizeof(_cppstruct) == sizeof(_c99struct) ) + +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Memory, bgfx_memory_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Transform, bgfx_transform_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Stats, bgfx_stats_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::VertexDecl, bgfx_vertex_decl_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientIndexBuffer, bgfx_transient_index_buffer_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientVertexBuffer, bgfx_transient_vertex_buffer_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InstanceDataBuffer, bgfx_instance_data_buffer_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TextureInfo, bgfx_texture_info_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::UniformInfo, bgfx_uniform_info_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Attachment, bgfx_attachment_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps::GPU, bgfx_caps_gpu_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps::Limits, bgfx_caps_limits_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps, bgfx_caps_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::PlatformData, bgfx_platform_data_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InternalData, bgfx_internal_data_t); + +#undef BGFX_C99_STRUCT_SIZE_CHECK + $c99 /* user define functions */ diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 98a64e4a1..dbe330a44 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -5233,42 +5233,6 @@ BX_STATIC_ASSERT( (0 #undef FLAGS_MASK_TEST -#define BGFX_C99_ENUM_CHECK(_enum, _c99enumcount) \ - BX_STATIC_ASSERT(_enum::Count == _enum::Enum(_c99enumcount) ) - -BGFX_C99_ENUM_CHECK(bgfx::Fatal, BGFX_FATAL_COUNT); -BGFX_C99_ENUM_CHECK(bgfx::RendererType, BGFX_RENDERER_TYPE_COUNT); -BGFX_C99_ENUM_CHECK(bgfx::Attrib, BGFX_ATTRIB_COUNT); -BGFX_C99_ENUM_CHECK(bgfx::AttribType, BGFX_ATTRIB_TYPE_COUNT); -BGFX_C99_ENUM_CHECK(bgfx::TextureFormat, BGFX_TEXTURE_FORMAT_COUNT); -BGFX_C99_ENUM_CHECK(bgfx::UniformType, BGFX_UNIFORM_TYPE_COUNT); -BGFX_C99_ENUM_CHECK(bgfx::BackbufferRatio, BGFX_BACKBUFFER_RATIO_COUNT); -BGFX_C99_ENUM_CHECK(bgfx::OcclusionQueryResult, BGFX_OCCLUSION_QUERY_RESULT_COUNT); -BGFX_C99_ENUM_CHECK(bgfx::Topology, BGFX_TOPOLOGY_COUNT); -BGFX_C99_ENUM_CHECK(bgfx::TopologyConvert, BGFX_TOPOLOGY_CONVERT_COUNT); -BGFX_C99_ENUM_CHECK(bgfx::RenderFrame, BGFX_RENDER_FRAME_COUNT); -#undef BGFX_C99_ENUM_CHECK - -#define BGFX_C99_STRUCT_SIZE_CHECK(_cppstruct, _c99struct) \ - BX_STATIC_ASSERT(sizeof(_cppstruct) == sizeof(_c99struct) ) - -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Memory, bgfx_memory_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Transform, bgfx_transform_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Stats, bgfx_stats_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::VertexDecl, bgfx_vertex_decl_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientIndexBuffer, bgfx_transient_index_buffer_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientVertexBuffer, bgfx_transient_vertex_buffer_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InstanceDataBuffer, bgfx_instance_data_buffer_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TextureInfo, bgfx_texture_info_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::UniformInfo, bgfx_uniform_info_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Attachment, bgfx_attachment_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps::GPU, bgfx_caps_gpu_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps::Limits, bgfx_caps_limits_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps, bgfx_caps_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::PlatformData, bgfx_platform_data_t); -BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InternalData, bgfx_internal_data_t); -#undef BGFX_C99_STRUCT_SIZE_CHECK - namespace bgfx { struct CallbackC99 : public CallbackI diff --git a/src/bgfx.idl.inl b/src/bgfx.idl.inl index f7f6b2ca1..33358b326 100644 --- a/src/bgfx.idl.inl +++ b/src/bgfx.idl.inl @@ -8,6 +8,44 @@ * */ +#define BGFX_C99_ENUM_CHECK(_enum, _c99enumcount) \ + BX_STATIC_ASSERT(_enum::Count == _enum::Enum(_c99enumcount) ) + +BGFX_C99_ENUM_CHECK(bgfx::Fatal, BGFX_FATAL_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::RendererType, BGFX_RENDERER_TYPE_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::Attrib, BGFX_ATTRIB_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::AttribType, BGFX_ATTRIB_TYPE_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::TextureFormat, BGFX_TEXTURE_FORMAT_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::UniformType, BGFX_UNIFORM_TYPE_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::BackbufferRatio, BGFX_BACKBUFFER_RATIO_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::OcclusionQueryResult, BGFX_OCCLUSION_QUERY_RESULT_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::Topology, BGFX_TOPOLOGY_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::TopologyConvert, BGFX_TOPOLOGY_CONVERT_COUNT); +BGFX_C99_ENUM_CHECK(bgfx::RenderFrame, BGFX_RENDER_FRAME_COUNT); + +#undef BGFX_C99_ENUM_CHECK + +#define BGFX_C99_STRUCT_SIZE_CHECK(_cppstruct, _c99struct) \ + BX_STATIC_ASSERT(sizeof(_cppstruct) == sizeof(_c99struct) ) + +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Memory, bgfx_memory_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Transform, bgfx_transform_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Stats, bgfx_stats_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::VertexDecl, bgfx_vertex_decl_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientIndexBuffer, bgfx_transient_index_buffer_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientVertexBuffer, bgfx_transient_vertex_buffer_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InstanceDataBuffer, bgfx_instance_data_buffer_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TextureInfo, bgfx_texture_info_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::UniformInfo, bgfx_uniform_info_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Attachment, bgfx_attachment_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps::GPU, bgfx_caps_gpu_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps::Limits, bgfx_caps_limits_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps, bgfx_caps_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::PlatformData, bgfx_platform_data_t); +BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InternalData, bgfx_internal_data_t); + +#undef BGFX_C99_STRUCT_SIZE_CHECK + BGFX_C_API void bgfx_attachment_init(bgfx_attachment_t* _this, bgfx_texture_handle_t _handle, bgfx_access_t _access, uint16_t _layer, uint16_t _mip, uint8_t _resolve) { bgfx::Attachment* This = (bgfx::Attachment*)_this;