Added C# bindings.

This commit is contained in:
Бранимир Караџић 2019-07-04 16:46:25 -07:00
parent 7184da2050
commit 7d047dfc5b
3 changed files with 1497 additions and 13 deletions

1482
bindings/cs/bgfx.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -94,7 +94,9 @@ end
local converter = {}
local yield = coroutine.yield
local function gen()
local gen = {}
function gen.gen()
local r = csharp_template:gsub("$(%l+)", function(what)
local tmp = {}
for _, object in ipairs(idl[what]) do
@ -290,7 +292,13 @@ function converter.funcs(func)
yield("internal static extern unsafe " .. convert_ret_type(func.ret) .. " " .. func.cname .. args .. ");")
end
print(gen())
-- printtable("idl types", idl.types)
-- printtable("idl funcs", idl.funcs)
function gen.write(codes, outputfile)
local out = assert(io.open(outputfile, "wb"))
out:write(codes)
out:close()
end
return gen

View File

@ -66,16 +66,10 @@ newaction {
generate("temp.bgfx.idl.inl", "../src/bgfx.idl.inl", "\t")
generate("temp.defines.h", "../include/bgfx/defines.h", "\t")
os.exit()
end
}
newaction {
trigger = "c#-idl",
description = "Generate bgfx C# bindings.",
execute = function ()
local csidl = require "csharp"
do
local csgen = require "csharp"
csgen.write(csgen.gen(), "../bindings/cs/bgfx.cs")
end
os.exit()
end