From cc24c4e99888a9b0a670d15c45d94b8cd19d4fc0 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, 6 Jul 2019 21:35:46 -0700 Subject: [PATCH] IDL: Updated codegen. --- scripts/bindings-cs.lua | 28 +++++----------------------- scripts/codegen.lua | 1 + 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/scripts/bindings-cs.lua b/scripts/bindings-cs.lua index a26f8af45..5b316ca8a 100644 --- a/scripts/bindings-cs.lua +++ b/scripts/bindings-cs.lua @@ -296,33 +296,15 @@ function converter.funcs(func) yield("[return: MarshalAs(UnmanagedType.LPStr)]") end - local first = "" - local args = "(" - + local args = {} if func.this ~= nil then - - local thisType = func.this:gsub("const ", "") - if thisType == "bgfx_encoder_t*" then - thisType = "Encoder*" - elseif thisType == "bgfx_attachment_t*" then - thisType = "Attachment*" - elseif thisType == "bgfx_vertex_decl_t*" then - thisType = "VertexDecl*" - end - - args = args .. thisType .. " " .. "_this" - first = ", " + args[1] = func.this_type.type .. "* _this" end - for _, arg in ipairs(func.args) do - - local argtype = convert_type(arg) - - args = args .. first .. argtype .. " " .. arg.name - first = ", " + table.insert(args, convert_type(arg) .. " " .. arg.name) end - - yield("internal static extern unsafe " .. convert_ret_type(func.ret) .. " " .. func.cname .. args .. ");") + yield("internal static extern unsafe " .. convert_ret_type(func.ret) .. " " .. func.cname + .. "(" .. table.concat(args, ", ") .. ");") end -- printtable("idl types", idl.types) diff --git a/scripts/codegen.lua b/scripts/codegen.lua index 12be5f50c..6eee7f04f 100644 --- a/scripts/codegen.lua +++ b/scripts/codegen.lua @@ -402,6 +402,7 @@ function codegen.nameconversion(all_types, all_funcs) local classtype = { fulltype = classname .. "*" } convert_arg(all_types, classtype, v) v.this = classtype.ctype + v.this_type = classtype v.this_conversion = string.format( "%s This = (%s)_this;", classtype.cpptype, classtype.cpptype) v.this_to_c = string.format("(%s)this", classtype.ctype) end